Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Getting Started with ASP.NET : Page 7

Learn what it takes to begin building ASP.NET Web sites with Visual Studio .NET. This article will provide you with the knowledge you need to jumpstart your foray into the world of ASP.NET development.


advertisement
RegularExpressionValidator
You can use the RegularExpressionValidator control to verify that the entry in a control conforms to a specified Regular Expression. This allows you to check an entry against a pattern such as a U.S. Social Security number, telephone number, email address, etc.

The following HTML code adds a RegularExpressionValidator named regPhoneNumber to watch over the txtPhone text box, which is also watched over by reqPhone, the RequiredFieldValidator:

<asp:RegularExpressionValidator id="regPhoneNumber" runat="server" ErrorMessage="Please enter a phone number!" ControlToValidate="txtPhone" ValidationExpression= "((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}"> </asp:RegularExpressionValidator></P>

Figure 13 shows the Property window for the regPhoneNumber RegularExpressionValidator control.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date