Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You may want to include validation on required fields. This will ensure that when user are interacting with the form they are providing the correct information and also this will cut down on invalid submissions.

...

The following examples were found on frevvo's documetation site linked at the top of this page.

US Zip Code Pattern

A pattern that restricts a text control to only allow strings formatted as a US zip code: ##### or #####-####:

Code Block
\d{5}|\d{5}-\d{4}

The form will flag an error unless the value entered is either five digits or five digits followed by the '-' character followed by 4 digits.

US/Canada Zip/Postal Code Pattern

This pattern validates US zip codes (##### or #####-####) and Canadian postal codes (L#L #L#).

Code Block
>(\d{5}(-\d{4}))|(\d{5})|([ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1})

SSN

This pattern ensures that the user enters a valid Social Security Number:

Code Block
\d{3}-\d{2}-\d{4}

Numbers with commas

The default number control supports digits followed by an optional decimal point and multiple decimal places. Suppose instead you want to allow numbers containing commas and optionally starting with a '$' and only up to 2 decimal places. For example: $1,000.50 2,500. But also to allow numbers without the comma such as $1000. To do this:

  • Add a text control to your form

  • Set the pattern to:

    Code Block
    \$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?

If you do not want to allow the optional '$' then:

  • Set the pattern to:

    Code Block
    ([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?

Phone pattern

A pattern such as ##-####-#### or ####-###-### is not a simple restriction. To impose validation against this pattern you must start with a Text control rather than a Phone control

Code Block
\d{2}-\d{4}-\d{4} or \d{4}-\d{3}-\d{3}

...