different validator
Check if the input value is different with given value
Options
Using with form field
(* denotes a required option)
Name | HTML attribute | Type | Description |
---|
compare * | data-fv-different___compare | String or a function returns a string | The value that the field has to be different with |
message | data-fv-different___message | String | The error message |
Using the ES6 module
import { different } from '/vendors/@form-validation/cjs/validator-different';
const result = different().validate({
value: ...,
options: {
compare: ...,
message: ...,
},
});
Using the npm package
- Install the validator package:
$ npm install @form-validation/validator-different
- Use the
different
validator:
import { different } from '@form-validation/validator-different';
const result = different().validate({
value: ...,
options: {
compare: ...,
message: ...,
},
});
Basic example
The registration form below doesn't allow the username and password to be the same:
See also
Changelog