Getting Started

ean validator

Validate an EAN (International Article Number)

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-ean___message String The error message
Using with ES6 module
            
// You might need to change the importing path
import ean from 'formvalidation/dist/es6/validators/ean' ;
const result = ean ( ) . validate ( {
value : ... ,
options : {
message : ... ,
} ,
} ) ;
/*
result is an object of
{
valid: true or false,
message: The error message
}
*/

Basic example

ean validator

ES6 Module Example

The following snippet shows how to use the ean validator with ES6 module:
            
// You might need to change the importing path
import ean from 'formvalidation/dist/es6/validators/ean' ;
const res1 = ean ( ) . validate ( {
value : '9780471117094' ,
options : {
message : 'The value is not valid EAN' ,
} ,
} ) ;
// res1.valid === true
const res2 = ean ( ) . validate ( {
value : '73513536' ,
options : {
message : 'The value is not valid EAN' ,
} ,
} ) ;
// res2.valid === false

See also

Changelog

v1.5.0
  • Support GTIN-14 format