id validator

Validate an identification number

Options

Use with form field

* presents a required option. The HTML attributes are used to set the validator options via the Declarative plugin

Name HTML attribute Type Description
country* data-fv-id___country String or Function An ISO-3166 country code
message data-fv-id___message String The error message

The validator supports the following countries (click the sample number to validate it):

Country Abbreviation ID system Country code Sample ID Is it valid?
Bosnia and Herzegovina BA
Brazil CPF BR 39053344705
390.533.447-05
111.444.777-35
231.002.999-00
000.000.000-00
Bulgari EGN BG 7523169263
8032056031
803205 603 1
8001010008
7501020018
7552010005
7542011030
8019010008
Chile RUN/RUT CL 76086428-5
22060449-7
12531909-2
China CN 450202201409072332
22011219930407001X
110108601017023
999999199304070016
Croatia OIB HR 33392005961
33392005962
Czech RC CZ 7103192745
991231123
1103492745
590312123
Denmark CPR DK 2110625629
211062-5629
511062-5629
Estonia isikukood EE 37605030299
Finland HETU FI 311280-888Y
131052-308T
131052-308U
310252-308Y
Iceland Kennitala IS 120174-3399
1201743399
0902862349
Ireland PPS IE 6433435F
6433435FT
6433435FW
6433435OA
6433435IH
1234567TW
1234567FA
6433435E
6433435VH
Latvia Personas kods LV 161175-19997
16117519997
161375-19997
Lithuania Asmens kodas LT 38703181745
38703181746
78703181745
38703421745
Macedonia MK
Montenegro ME
Netherlands BSN NL 111222333
941331490
9413.31.490
Poland PESEL PL 83010411457
87123116221
39100413824
36032806768
04271113861
Romania CNP RO 1630615123457
1800101221144
8800101221144
1632215123457
1630615123458
San Marino SM
Serbia RS
Slovakia RC SK 7103192745
991231123
7103192746
1103492745
Slovenia EMŠO SI 0101006500006
South Africa South African ID ZA 8001015009087
8001015009287
8001015009086
Spain DNI/NIE/CIF ES 54362315K
54362315-K
X2482300W
X-2482300W
X-2482300-W
54362315Z
X-2482300A
Sweden personnummer SE 8112289874
811228-9874
811228+9874
811228-9873
Switzerland AHV-Nr/No AVS CH 756.1234.5678.95
7561234567895
Thailand TH 7145620509547
3688699975685
2368719339716
1100800092310

Use with JavaScript module


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

const result = id().validate({
    value: ...,
    options: {
        // Can be a string or a function returns a string
        country: ...,
        message: ...,
    },
});
/*
result is an object of
{
    valid: true or false,
    message: The error message
}
*/

Basic Example

You can click on sample from the table above to see if it's a valid or invalid id.

Module Example

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


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

const res1 = id().validate({
    value: '54362315K',
    options: {
        country: 'ES',
        message: 'The value is not a valid ID',
    },
});
// res1.valid === true

const res2 = id().validate({
    value: '511062-5629',
    options: {
        country: 'DK',
        message: 'The value is not a valid ID',
    },
});
// res2.valid === false

Related validators

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

Name Description
vat Validate VAT number