Regular Expression Validation examples

By Kateryna Sytnyk

December 12, 2008

Email Validation

  

<span id="vpropertyEmailValid"

controltovalidate="frmEmail"

errormessage="Email must be valid"

display="Dynamic"

evaluationfunction="RegularExpressionValidatorEvaluateIsValid"

validationexpression= "^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$"

class="mystarhidden">

You must enter a valid email address.

</span>

 


 

 

 

Zip code

 

<span id="vpropertyZipValid"

controltovalidate="frmZip"

errormessage="Zip must be valid"

display="Dynamic"

evaluationfunction="RegularExpressionValidatorEvaluateIsValid"

validationexpression= "\d{5}"

class="mystarhidden">

You must enter a valid zip code.

</span>

 

 

 

 


 

DNN password

 

<span id="vpropertyPasswordValid"

controltovalidate="frmPassword"

errormessage="Passwords must be at least 7 characters in length"

display="Dynamic"

evaluationfunction="RegularExpressionValidatorEvaluateIsValid"

validationexpression= "\w{7,}"

class="FormValidationError">

Passwords must be at least 7 characters in length

</span>

 

 


 

Phone Number

 

<span controltovalidate="frmPhoneNumber"

errormessage="Phone number must be valid"

display="Dynamic"

evaluationfunction="RegularExpressionValidatorEvaluateIsValid"

validationexpression= "^\(?[\d]{3}\)?[\s-]?[\d]{3}[\s-]?[\d]{4}$" 

class="errormessage">

You must enter a valid phone number.

</span>

 


URL

 

<span controltovalidate="frmUrl"

errormessage="Url must be valid"

display="Dynamic"

evaluationfunction="RegularExpressionValidatorEvaluateIsValid"

validationexpression= "(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*"

class="errormessage">

You must enter a valid URL.

</span>

 


 

 

Average (0 Ratings):
 
Want to help out?
 
 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seattle, WA • info@openwebstudio.com

Bookmark & Share Bookmark and Share