vin validator

Validate an US VIN (Vehicle Identification Number)

Options

Use 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-vin___message String The error message

Use with JavaScript module


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

const result = vin().validate({
    value: ...,
    options: {
        message: ...,
    },
});
/*
result is an object of
{
    valid: true or false,
    message: The error message
}
*/

Basic Example

You can click on sample to see if it's a valid or invalid VIN.

Sample Is valid?
1FAHP26W49G252740
2FTRX07W53C371582
WP0CA29863U153381
JTMKF4DV5B5309254

Module Example

The following snippet shows how to use the vin validator with JavaScript module:


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

const res1 = vin().validate({
    value: '192.168.1.1',
    options: {
        message: 'The value is not valid IP address',
    },
});
// res1.valid === true

const res2 = vin().validate({
    value: 'JTMKF4DV5B5309254',
    options: {
        message: 'The value is not valid VIN',
    },
});
// res2.valid === false