Tag Archives: validation

Xform field validation using regular expression

xform regular expression for validation

Title Expression Example
US phone validation      /^\(?(\d{3})\)?[-\. ]?(\d{3})[-\. ]?(\d{4})$/ 555-555-1212, (555)-555-1212), 555 555 1212, 555.555.1212, (555).555.1212
UK Phone Validation     /^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$/  07222 555555, (07222) 555555, +44 7222 555 555
ZIP code validation    /^[0-9]{10}$/
Image Validation   /image\/jpeg|image\/png|image\/gif|image\/jpg/  jpg, png and gif
PDF file validation  /application\/pdf|application\/x-pdf/
String Length   /^[a-zA-Z]{3,7}$/   Min length 3 and max length is 7