Documentation

Validators

Or copy link

Validators

Estimated reading: minutes 6 views

6 views
Min read

Validators can be added to each of the form elements to establish a validation for the specific field. The validity will be checked when the user fills up the form. You can check the different validators provided by the TYPO3 form extension. Reference link: https://docs.typo3.org/c/typo3/cms-form/main/en-us/E/Validators/Index.html

Alphanumeric

  1. The validator checks whether the field contains an alphanumeric string only.
  2. “Alphanumeric” defines a combination of alphabetic and numeric characters. No special characters can be entered, only characters from [A-Z] and [0-9].
  3. The settings of the validator are as follows:
    1. Custom error message: Custom error message that will be shown if the validation fails.
  4. The validator is available for the following form elements:
    1. Text
    2. Textarea
    3. Password
    4. Advanced password

String length

  1. The validator uses the minimum and maximum values to check how many characters can be entered. The settings of the validator are as follows:
    1. Minimum: How many characters the field must contain as a minimum.
    2. Maximum: How many characters the field may contain as a maximum.
    3. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    1. Text
    2. Textarea
    3. Password
    4. Advanced password

Email

  1. The validator checks whether the entered value is a valid email address. The default allows international characters and multiple occurrences of the @ sign. The settings of the validator are as follows:
    1. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    1. Text
    2. Email address (validator is automatically active)
    3. Password
    4. Advanced password

Integer number

  1. The validator checks whether the entered value is a valid integer. No numbers with commas can be entered. The settings of the validator are as follows:
    1. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    1. Text
    2. Textarea
    3. Password
    4. Advanced password

Floating-point number

  1. The validator checks whether the entered value is a valid floating-point number. Only numbers with a comma can be entered. The settings of the validator are as follows:
    1. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    1. Text
    2. Textarea
    3. Password
    4. Advanced password

Number

  1. The validator checks whether the entered value is a valid number. Only numbers without a comma can be entered. The settings of the validator are as follows:
    1. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    1. “Number” (validator is automatically active)

Number range

  1. The validator checks if the entered value is a number within the specified number range. The settings of the validator are as follows:
    1. Minimum: The minimum value to accept.
    2. Maximum: The maximum value to be accepted.
    3. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    1. Text
    2. Textarea
    3. Password
    4. Advanced password
    5. Number

Regular expression

  1. The validator checks whether the entered value matches the specified regular expression. The settings of the validator are as follows:
    1. Regular expression: The regular expression to use for validation.
    2. Custom error message: Custom error message that will be shown if the validation fails.
  2. Imagine the following example. You want the user to specify a domain name. The value entered should contain only the domain, for example, “docs.typo3.org” instead of “https://docs.typo3.org“. The regular expression for this use case would be /^[a-z]+.[a-z]+.[a-z]$/.
  3. The validator is available for the following form elements:
    1. Text
    2. Textarea
    3. Password
    4. Advanced password
    5. Telephone number
    6. URL

Date range

  1. The validator checks whether the entered value is within the specified date range. The range can be defined by specifying a start and/ or end date. The settings of the validator are as follows:
    1. Start date: Select the beginning of the date range (input: YYYY-MM-DD).
    2. End date: Select the end of the date range (input: YYYY-MM-DD).
    3. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    1. Date

Number of submitted values

  1. The validator checks whether the entered value, which is defined in a minimum and a maximum, contains the specified number of elements. The settings of the validator are as follows:
    1. Minimum: The minimum number of values submitted.
    2. Maximum: The maximum number of submitted values.
    3. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    • Multi checkbox
    • Multi select

File size

  1. The validator checks a file resource for its file size. The settings of the validator are as follows:
    1. Minimum: The minimum file size that is accepted (default: 0B).
    2. Maximum: The maximum file size that will be accepted (default: 10M).
  2. Use the format B | K | M | G (byte | kilobyte | megabyte | gigabyte) when entering file sizes. For example: 10M means 10 megabytes. Please note that the maximum file size also depends on the settings of your server environment.
  3. The validator is available for the following form elements:
    1. File upload
    2. Image upload

Date/ Time

  1. The validator checks if the entered value is a valid date and/ or time. The settings of the validator are as follows:
    1. Custom error message: Custom error message that will be shown if the validation fails.
  2. The validator is available for the following form elements:
    1. Date picker (jQuery)
Share

Leave a Comment