Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WDESIGNER and version 21.1_b

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 field should contain an @ signa valid email address. A validation of entries can be done using regular expressions.

The form element Text Box therefore contains the attribute Regular Expression where 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.

Special Characters in Regular Expressions

The following characters have special meaning in regular expressions:

CharactersDescription ^ 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.
Example: When checking for a | b, input a would be as valid as input b, but input c would not.

[ ]

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.
Example: [1234] checks the same as [1-4]. Valid entries are 2 pears as well as 3 apples.

[^]

The combination of square brackets and circumflex stands for a negated selection.
Example: [^123] means that all entries that do not contain 1, 2 or 3 are valid.

{ }The curly braces help to query frequencies.
Examples:
{n} The preceding element occurs exactly n times.
{n,m} The preceding character occurs n to m times.
{0,n} The preceding element occurs zero to n times.
{n,} The preceding character occurs at least n times.
Tip

See ICU's Regular Expressions package for an overview of regular expression metacharacters and operators.

\

The backslash helps if you want to find characters that cannot be entered using the keyboard.
Examples:
\0 finds the null character
\s finds all white spaces
\t finds the tab character
\n finds the line break character

\sThe s stands for white space. \s finds all Unicode spaces, i.e. spaces, breaks, tabs and typographical special spaces.
Tip

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 helpful regular expressions for you here:

A limitation of the password to a certain number of characters can also be checked.
Example: A password which may contain upper and lower case letters (but no umlauts), numbers digits and the special characters §, %, & but no umlauts and . And the input must consist of at least 8, but not more than 16 characters.
Regular ExpressionDescription
\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.
Use Case
^[0-9]{5}$Only digits are accepted as input and exactly five digits must be enteredare accepted.
Validate a German zip code.
^[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 Check the input 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]+Only letters and numbers are allowed.Prevent usage of special characters in the input.
[a-zA-a-zA-Z0-9 öäüÖÄÜ §%&]*$Allowed input: Any number of small upper and capital lower case letters, the numbers 0 to 9 as well as the digits, 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-zA-Z0-9§%&]{8,16}Allowed input: Upper
Tip
Suitable for checking a password that may only contain the special characters specified in the regular expression and must have a certain length.
^[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.
^9._-]+@[a-zA-Z0-9._-]+\.[a-z]{02,5}$ Only a maximum of 5 letters and numbers are accepted. No spaces, umlauts or special characters.

Allowed input:

  • String (containing letters, digits, dot, underscore or minus) followed by an @-sign and another string (containing letters, digits, dot, underscore or minus) followed by a dot and two or more letters.
Validate the input of an email address.
(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-z]{2,5}(:[0-9]{1,}$5})?(\/.*)?

Allowed input:

  • URL with prefix http://
  • URL with prefix https://
  • URL without prefix
Checks if the input contains a valid URLChecks whether a valid e-mail address has been entered.
Tip

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.


Otp
Floatingfalse
maxHLevel2

Rp