Validating Form Fields
Why Validate Content?
The simplest way of validation is to mark a form element as mandatory. The validation then checks whether the element has been filled with content as required.
A second validation level is to validate the field contents themselves, for example to prevent incorrect or incomplete entries. For example, an input field for (German) postal codes should consist of exactly five digits or an e-mail address should contain an @ sign. A validation of entries can be done using regular expressions.
The following form elements therefore contain the configuration option Validation Expression:
Input Field (Mobile)
In this field you can enter the desired regular expressions. When validating the data entered in the input field, the system then checks whether the entries comply with the required rules.
Time of the Validation
Responsive Forms | Mobile Forms |
---|---|
|
|
Special Characters in Regular Expressions
The following characters have special meaning in regular expressions:
Characters | Meaning |
---|---|
^ | The circumflex stands for the beginning of the input. |
$ | The dollar symbol marks the end of an entry. |
* | The asterisk represents any number. The preceding character may not occur at all or may occur any number of times. |
. | The dot stands for any single character. |
+ | The plus sign means: The preceding element must occur at least once. |
? | The question mark asks if the preceding element does not occur at all or occurs exactly once. |
| | The vertical line ("pipe") means: Either - Or. |
[ ] | The square brackets enclose a character selection. The expression is valid if one of the characters occurs in the input. A hyphen can be used to define a range within the parentheses. |
[^] | The combination of square brackets and circumflex stands for a negated selection. |
{ } | The curly braces help to query frequencies. |
\ | The backslash helps if you want to find characters that cannot be entered using the keyboard. |
For a complete list of the special characters used in regular expressions, see https://developer.mozilla.org.
Helpful Regular Expressions
We have compiled a list of frequently used regular expressions for you here:
Regular Expression | Meaning |
---|---|
\s | The s stands for white space. \s finds all Unicode spaces, i.e. spaces, breaks, tabs and typographical special spaces. |
\s* | The field may not contain any or any number of spaces. |
^.{2,10}$ | Limits the number of characters that can be entered to a minimum of 2 and a maximum of 10. |
.+@.+ | Checks whether the input contains an @ character. |
[0-9] | Only numbers with the digits zero to nine are accepted as input. |
^[0-9]+$ | Only numbers are accepted as input and the field must not remain empty. |
^[0-9]{5}$ | Only digits are accepted as input and exactly five digits must be entered. |
^[0-9/ -]*$ | The field may only contain (any number of) digits, slash, space and minus sign, or it may be blank. This expression can be used, for example, to validate the entry of phone numbers. |
^[0-9.,]*$ | The field may only contain (any number of) digits, periods and commas or may be empty. This expression can be used, for example, to check the entry of prices or numbers with thousands separators. |
^[A-Z]*$ | Only (any number of) capital letters may be entered (without umlauts). |
^[a-z]*$ | Only (any number of) lower case letters may be entered (without umlauts). |
^[a-zA-Z]*$ | Any number of lowercase and uppercase letters may be entered (without umlauts). |
^[a-zA-Z ]*$ | You can enter any number of lowercase and uppercase letters including spaces (without umlauts). |
^[a-zA-Z öäüÖÄÜß]*$ | Any number of upper and lower case letters including umlauts and ß are allowed. |
a-zA-Z0-9 öäüÖÄÜ §%&]*$ | Any number of small and capital letters, the numbers 0 to 9 as well as the umlauts and the special characters §, %, & are permitted. Suitable, for example, for checking a password that may only contain the special characters specified in the regular expression. A limitation of the password to a certain number of characters can also be checked. ^[a-zA-Z0-9§%&]{8,16}$ |
^\D*$ | Any number of entries other than decimal-numeric characters (letters, umlauts, special characters, but no numbers) are allowed. |
^[a-zA-Z0-9]{0,5}$ | Only a maximum of 5 letters and numbers are accepted. No spaces, umlauts or special characters. |
^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-z]{2,}$ | Checks whether a valid e-mail address has been entered. |
Further helpful hints on regular expressions can be found at https://wiki.selfhtml.org. A tester for self-created regular expressions can be found at http://www.regexpal.com.
Related Pages: