id validator

Validate a Spanish identification number

Basic Example

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

Sample ID Is it valid?
54362315K
54362315-K
X2482300W
X-2482300W
X-2482300-W
54362315Z
X-2482300A

Module Example

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


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

const res1 = esId().validate('X-2482300W');
// res1.valid === true

const res2 = esId().validate('X-2482300A');
// res2.valid === false

Related validators

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

Name Description
id Validate an identification number
vat Validate VAT number