Spilman Software Design
Home>
About
Contact
Demo>

RegularExpressionValidator example - June 2009
.NET 3.x ASP.NET
A pattern regex was needed for the common password requirements. The criteria had to work in both IE8 and FireFox. After testing all was good until I tested IE7. Turns out there is an issue with RegularExpressionValidator and IE7. See Custom Validator example.

Here is the regular expression for a password field that needs to be greater than or equal to six but less than or equal to twelve characters. Also at least one special character 0 through 9 or @#$%&+= symbol is needed.

Add a RegularExpressionValidator and point to your textbox and the attribute "ValidationExpression" will equal:
^(?=.*[0-9@#$%&+=])(?=.*[a-zA-Z]).{6,12}$
You may also want to add a RequiredFieldValidator validator.




Download demo

Translate This Page
v