digits validator

Check if the input contains only digits


Using with form field

The HTML attributes are used to set the validator options via the Declarative plugin

Name HTML attribute Type Description
message data-fv-digits___message String The error message

Using with JavaScript module

// You might need to change the importing path
import digits from 'formvalidation/validators/digits';

const result = digits().validate({
    value: ...,
    options: {
        message: ...,
result is an object of
    valid: true or false,
    message: The error message     

Related validators

The following validators are similar to this one and might be useful to you.

Name Description
integer Validate an integer number. Accept both positive and negative number
numeric Check if the value is numeric