Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

text-mask-vat-id

dimitrinicolas466MIT1.0.2

Text mask for VAT identification number

text-mask, vat, tva, btw-nr, mwst-nr, ддс, pdv-id, oib, φπα, dič, cvr, kmkr, alv nro momsnummer, ust-idnr, αφμ, anum, cbl, p.iva, pvn, nip, nipc, nif, cif, ič dph, id za ddv, momsnr, nipt, abn, унп, bn, vsk, vat tin, cst tin, npwp, nzbn, orgnr, инн, c.o.e., mwst, інпп, стир, cuit, cnpj, cpf, rut, ruc, nit, rtn, rnc, rif

readme

text-mask-vat-id Build Status Coverage Status

Text Mask function for VAT identification number.

Example

Demo available here: dimitrinicolas.github.io/text-mask-vat-id/example

Installation

npm i text-mask-vat-id

Usage

I recommend you to add an uppercase pipe function to text-mask component:

function upperCasePipe(value) {
  return value.toUpperCase();
}

With React.js

import React from 'react'
import MaskedInput from 'react-text-mask'
import createVatIdMask from 'text-mask-vat-id';

const mask = createVatIdMask();

export default () => (
  <MaskedInput
    mask={mask}
    pipe={value => value.toUpperCase()} />
);

In Vanilla JS

<script src="./node_modules/vanilla-text-mask/dist/vanillaTextMask.js"></script>
<script src="./node_modules/text-mask-vat-id/dist/text-mask-vat-id.umd.min.js"></script>
<script>
  function upperCasePipe(value) {
    return value.toUpperCase();
  }

  vanillaTextMask.maskInput({
    inputElement: document.getElementById('vat-input'),
    mask: createVatIdMask(),
    pipe: upperCasePipe
  });
});
</script>

Options

You can pass options as an object when creating text mask:

const mask = createVatIdMask({
  /** options */
});
  • localeFormat (default: false): If the mask should add separation characters (, -, . and /) to the VAT ID. E.g.: "FR19845015858" would become "FR 19 845 015 858".

Build

Compile with Rollup:

npm run build

Build and test:

npm test

Source

  • text-mask - Input mask for React, Angular, Ember, Vue, & plain JavaScript

License

This project is licensed under the MIT license.

changelog

Change Log

This project adheres to Semantic Versioning.

1.0.2 - 2020-03-11

Changed

  • Use only alphabetical characters in country code mask regexp (Issue #8)

1.0.1 - 2020-03-11

  • No update.

1.0.0 - 2019-03-11

  • Initial release.