digits validator

Check if the input contains only digits

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
NameHTML attributeTypeDescription
messagedata-fv-digits___messageStringThe error message
Using with ES6 module
// You might need to change the importing path
import digits from 'formvalidation/dist/es6/validators/digits';
const result = digits().validate({
value: ...,
options: {
message: ...,
},
});
/*
result is an object of
{
valid: true or false,
message: The error message
}
*/

See also