Params Validator element

The goal of the Validator element is to ensure that the user provides the necessary and properly formatted information needed to successfully complete an operation.

The Validator can only be used in combination with other fields:

Available validators:

nameDescriptionParameter required

req

Required value.

No

alpha

Alphabetic value.

No

alphanum

Alphanumeric value.

No

dec

Decimal value.

No

num

Numeric value.

No

email

E-mail value.

No

url

URL value.

No

maxlen

Set the maximum length allowed.

Yes

minlen

Set the minimum length required.

Yes

lt

Less than.

Yes

gt

Greater than.

Yes

min

Minimum value.

Yes

max

Maximum value.

Yes

regexp

Regular expression.

Yes

plugin

Create your own form validator.

More information at Creating your own Form Validator plugin.

Yes

Parent:

Basic example

  • Value is required "req".
  • Value must be a decimal value "dec".
  • The maximum length of the decimal value is 6 digits "maxlen".
<input label="Decimal value" name="decimal">
    <validator type="dec"/>
    <validator type="req"/>
    <validator type="maxlen" parameter="6"/>
</input>

Regular expression

If you want a validation that is not included in these predefined ones, you can use a regular expression. For example, imagine you want to restrict an input to lowercase ASCII values:

<input label="Lowercase value" name="regExp">
    <validator type="regexp" parameter="[a-z]+" />
</input>
Table of contents [ Hide Show ]