callback validator

Check if the input value passes a callback method

Options

Using with form field

* presents a required option. The HTML attributes are used to set the validator options via the Declarative plugin

Name HTML attribute Type Description
callback* data-fv-callback___callback Function The callback method
message data-fv-callback___message String The error message

The callback method must follow the format below:

If you want to return a dynamic message, the callback function must return an object containing the valid and message members:

Tip

Look at the Alias plugin if you want to have multiple callbacks on the same field

Using with ES6 module

Basic Example

In the following form, user is asked to enter a correct answer of simple operation which is generated randomly.

ES6 Module Example

The following snippet shows how to use the callback validator with ES6 module to check if a password is strong or weak:

More examples

Related validators

The following validators might be useful to you.