ASP.Net Regular Expression Validator to validate Minimum and Maximum Text Length
 
Author:
Filed Under: ASP.Net  |  ASP.Net Validators
Published Date: Jun 14, 2011
Views: 5431
 

Abstract: Here Mudassar Ahmed Khan has provided ASP.Net Regular Expression Validator samples to validate Minimum and Maximum text Length and also different configurations like Alphanumeric with special characters,Alphanumeric,Alpha and Numeric configurations.

Comments:  1

 

Below is the regular expression validator for specifying Minimum and Maximum Password length.
Below are the different configurations of the validator.
 
Alphanumeric with special Characters
Minimum length 7 and Maximum length 10. Characters allowed – a - z  A - Z 0-9 ’@ & # .
<asp:RegularExpressionValidator ID="RegExp1" runat="server"    
ErrorMessage="Password length must be between 7 to 10 characters"
ControlToValidate=" txtPassword "    
ValidationExpression="^[a-zA-Z0-9'@&#.\s]{7,10}$" />
 
Alphanumeric Only
Minimum length 7 and Maximum length 10. Characters allowed – a - z  A - Z 0-9
<asp:RegularExpressionValidator ID="RegExp1" runat="server"    
ErrorMessage="Password length must be between 7 to 10 characters"
ControlToValidate=" txtPassword "    
ValidationExpression="^[a-zA-Z0-9\s]{7,10}$" />
 
Alphabets Only
Minimum length 7 and Maximum length 10. Characters allowed – a - z  A - Z
<asp:RegularExpressionValidator ID="RegExp1" runat="server"    
ErrorMessage="Password length must be between 7 to 10 characters"
ControlToValidate="txtPassword"    
ValidationExpression="^[a-zA-Z]{7,10}$" />
 
Numeric Only
Minimum length 7 and Maximum length 10. Characters allowed – 0 - 9
<asp:RegularExpressionValidator ID="RegExp1" runat="server"    
ErrorMessage="Password length must be between 7 to 10 characters"
ControlToValidate="txtPassword"    
ValidationExpression="^[0-9]{7,10}$" />








Related Articles



Comments



Add comments

You can add your comment about this article using the form below. Make sure you provide a valid email address
else you won't be notified when the author replies to your comment

Please note that all comments are moderated and will be deleted if they are
  • Not relavant to the article
  • Spam
  • Advertising campaigns or links to other sites
  • Abusive content.
Please do not post code, scripts or snippets.

Name*: Required
Email*: Required
Comment*: Required
Security code*: CaptchaInvalid Security Code
  Submit