vat validator

Validate a VAT 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
country* data-fv-vat___country String or Function An ISO-3166 country code
message data-fv-vat___message String The error message

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

# Country Abbreviation VAT system Country code Sample VAT Is it valid?
1 Argentina - AR undefined
2 Austria UID AT undefined
3 Belgium n° TVA / BTW-nr / Mwst-nr BE undefined
4 Brazil CNPJ BR undefined
5 Bulgaria ДДС номер BG undefined
6 Croatia PDV-ID; OIB HR undefined
7 Cyprus ΦΠΑ CY undefined
8 Czech Republic DIČ CZ undefined
9 Denmark CVR DK undefined
10 Estonia KMKR EE undefined
11 Finland ALV nro FI undefined
12 France n° TVA FR undefined
13 Germany USt-IdNr. DE undefined
14 Greece ΑΦΜ GR undefined
15 Hungary ANUM HU undefined
16 Iceland VSK IS undefined
17 Ireland VAT no IE undefined
18 Italy P.IVA IT undefined
19 Latvia PVN LV undefined
20 Lithuania PVM kodas LT undefined
21 Luxembourg No. TVA LU undefined
22 Malta Vat No. MT undefined
23 Netherlands Btw-nr. NL undefined
24 Norway Orgnr NO undefined
25 Poland NIP PL undefined
26 Portugal NIF / NIPC PT undefined
27 Romania CIF RO undefined
28 Russia ИНН RU undefined
29 Serbia PIB RS undefined
30 Slovakia IČ DPH SK undefined
31 Slovenia ID za DDV SI undefined
32 South Africa - ZA undefined
33 Spain NIF / CIF ES undefined
34 Sweden Momsnr. SE undefined
35 Switzerland MWST / TVA / IVA CH undefined
36 United Kingdom VAT Reg No GB undefined
37 Venezuela RIF VE undefined

Using with JavaScript module


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

const result = vat().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 VAT.

Module Example

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


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

const res1 = vat().validate({
    value: 'U13585627',
    options: {
        country: 'AT',
        message: 'The value is not a valid VAT number',
    },
});
// res1.valid === true

const res2 = vat().validate({
    value: '13585627',
    options: {
        country: 'DK',
        message: 'The value is not a valid VAT number',
    },
});
// 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