Validation in ASP.NET
page 3 of 9
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 31141/ 161

Using Regular Expressions

Regular Expressions

I never really got the hang of regular expressions, but I can do some very simple things. Now if your putting all of my code into a file to test it, just add this one below the last. Remember that you aren't limited to one validator per control, you can have as many as you like!

<asp:RegularExpressionValidator runat="Server" ControltoValidate="FName" ErrorMessage="Your name isn't in the correct format!" ValidationExpression="\S+\s\S+" />

Now this checks to see weather the field matches the pattern in the ValidationExpression property, in this case the pattern in - "Any number of non-space characters, followed by one space, followed by any number of non-space characters", this is the normal format for a name.

For more resources on regular expressions see - http://www.4guysfromrolla.com/webtech/regularexpressions.shtml


View Entire Article

User Comments

Title: Nice   
Name: Nagesh
Date: 2004-07-13 9:49:31 AM
Comment:
Thanks for such quick review ....
Title: GOOD   
Name: NAGESH
Date: 2004-07-13 8:28:00 AM
Comment:
But where is the code!!!!!!!!!!!!!!!!!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-08-19 4:30:49 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search