locked
Adding required field validators to a form RRS feed

  • Question

  • I have a form connected to a database so you can add new customers in it. I need to add required field validators and change them so they have a certain format (SSN is 999-99-9999). I can't get the required field validators to work .. Any ideas?
    • Moved by Jason Dot Wang Monday, April 29, 2013 8:23 AM This thread is about ASP.NET
    Thursday, April 25, 2013 5:48 PM

Answers

All replies

  • Hi,

    It seems to me you want a http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.regularexpressionvalidator.aspx validator (to check that it match the pattern you want) rather than the required field validator (which just check if you have an input in a required field).

    If you need further hel, please close this thread and post to http://forums.asp.net rather than to a general C# forum.


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Thursday, April 25, 2013 6:03 PM
  • It requires regularexpression validator ...Codes following below

      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="enter in correct format to SSN(999-88-9999)" ValidationExpression="\d{3}-\d{2}-\d{4}"></asp:RegularExpressionValidator>
         


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Thursday, April 25, 2013 6:06 PM
  • When I try to add a validators, I can't connect it to what I'm trying to validate. Nothing shows up under the control to validate field
    Thursday, April 25, 2013 6:23 PM
  • Absolutely it will not display anything at page load. but when you will put wrong inputs and click your submit button that time Validator message will show  


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Thursday, April 25, 2013 6:45 PM
  • Still couldn't get it to work. The validator won't link to what I want it to
    Friday, April 26, 2013 2:02 AM
  • Hi guy,

      Welcome to MSDN Forum Support.

     

      You are more likely to get more efficient responses to ASP.NET issues at http://forums.asp.net where you can contact ASP.NET experts.

      Sincerely,

      Jason Wang



    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 29, 2013 8:23 AM