imei validator

Validate an IMEI (International Mobile Station Equipment Identity)

Options

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

Using with JavaScript module


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

const result = imei().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 IMEI.

Sample Is valid?
35-209900-176148-1
35-209900-176148-23
3568680000414120
490154203237518
490154203237517

Module Example

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


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

const res1 = imei().validate({
    value: '35-209900-176148-1',
    options: {
        message: 'The value is not valid IMEI',
    },
});
// res1.valid === true

const res2 = imei().validate({
    value: '490154203237517',
    options: {
        message: 'The value is not valid IMEI',
    },
});
// res2.valid === false

Related validators

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

Name Description
meid Validate a MEID (mobile equipment identifier)