Getting Started
Events

vat validator

Validate VAT numbers in different countries

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
(* denotes a required option)
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:
Country Abbreviation VAT system Country code
Argentina - AR
Austria UID AT
Belgium n° TVA / BTW-nr / Mwst-nr BE
Brazil CNPJ BR
Bulgaria ДДС номер BG
Croatia PDV-ID; OIB HR
Cyprus ΦΠΑ CY
Czech Republic DIČ CZ
Denmark CVR DK
Estonia KMKR EE
Finland ALV nro FI
France n° TVA FR
Germany USt-IdNr. DE
Greece ΑΦΜ GR
Hungary ANUM HU
Iceland VSK IS
Ireland VAT no IE
Italy P.IVA IT
Latvia PVN LV
Lithuania PVM kodas LT
Luxembourg No. TVA LU
Malta Vat No. MT
Netherlands Btw-nr. NL
Norway Orgnr NO
Poland NIP PL
Portugal NIF / NIPC PT
Romania CIF RO
Russia ИНН RU
Serbia PIB RS
Slovakia IČ DPH SK
Slovenia ID za DDV SI
South Africa - ZA
Spain NIF / CIF ES
Sweden Momsnr. SE
Switzerland MWST / TVA / IVA CH
United Kingdom VAT Reg No GB
Venezuela RIF VE
Using with ES6 module
            
// You might need to change the importing path
import vat from 'formvalidation/dist/es6/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

vat validator

ES6 Module Example

The following snippet shows how to use the vat validator with ES6 module:
            
// You might need to change the importing path
import vat from 'formvalidation/dist/es6/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

See also

Changelog

v1.8.0
  • The Bulgarian VAT validator doesn't work for some VAT numbers
  • The French VAT validator doesn't work for some VAT numbers
v1.7.0
  • Support new format of Dutch VAT number
v1.6.0
  • Fixed an issue that the country option isn't passed to the placeholder message
v1.4.0
  • Separate vat validators to vat package to save imports when using with ES6 module
  • Support the Argentinian VAT number
  • Support the Swiss VAT numbers that end with TVA, IVA, TPV