Category Archives: Xform

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}|\(?\d{5}\)?)\s?\d{3}\s?\d{3}$/ 07222 555555, (07222) 555555, +44 7222 555 555
ZIP code validation    /^[0-9]{10}$/
UK postal validation    /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/i
Image Validation   /image\/jpeg|image\/png|image\/gif|image\/jpg/  jpg, png and gif
PDF file validation  /application\/pdf|application\/x-pdf/
Alphabet String Length   /^[a-zA-Z]{3,7}$/   Min length 3 and max length is 7
Any String Length   /^.{5,20}$/   Min length 5 and max length is 20

how to overwrite default contact page by xform’s form?

You will have to follow following steps if you want to overwrite default contact form by form created by xform.

  1. Enable layout module option in Xform -> Integration.
  2.  Add following css rule Xform -> Other Tab into Custom CSS section. This is needed to hide default contact form.

3. Now navigate to Design -> Layout , Now edit Contact Layout. Finally add your form at Content bottom position.

That’s all.

 

How to show xform data in a custom template?

For showing form data/records in the information page, you will have to place shortcode [xformdata id=formID limit=20][/xformdata]. Surely you will have to place your form ID in place of formID

By default data will be shown as tabular format but you can show data in your customized template. In that case you will have to place your template inside shortcode. For example:

[xformdata id=formID limit=20]YOUR_TEMPLATE[/xformdata]

You can make your template ready by placing xform placeholders for getting form data.

Lets make template using above placeholders shown in the screenshots.

[xformdata id=formID limit=20]<div>{c2.value}</div><div>{c17.value}</div><div>{c4.value}</div>[/xformdata]