About Visual Basic has featured articles introducing validation techniques for ASP.NET - "ASP.NET - Learn Programming for the Networked World - Part 2" and articles about how to use Regular Expressions - Introduction to Regular Expressions in Visual Basic. But there has not been an article at the site that talked about the two together. And that's a real miss because the RegularExpressionValidator control for ASP.NET is a powerful combination. (Note ... I will use the shorthand "regex" to mean "regular expression" in the remainder of this article.)
The other ASP.NET validation controls let you check for required values, comparisons and ranges, and even provide the ability to code any validation that you like in a custom event handler called by ASP.NET. But since validation is really checking text, and regexes are the premier way to check text, the RegularExpressionValidator control is just a natural fit!
The basic idea behind using the RegularExpressionValidator control is to add the control to a web form that also contains the control to be validated. Add the ID of the control to be validated and the actual regex code to the ValidationExpression property of the RegularExpressionValidator control ... and you're good to go! This does "Server Side" validation. You can also validate with client script and I'll show you a simple example after we get the initial application working.


