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

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 -

View Entire Article

User Comments

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

Product Spotlight
Product Spotlight 

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

©Copyright 1998-2021  |  Page Processed at 2021-03-04 8:27:14 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search