https://github.com/dimitrinicolas/text-mask-vat-id
Text Mask for VAT identification number
https://github.com/dimitrinicolas/text-mask-vat-id
text-mask tva vat
Last synced: 6 months ago
JSON representation
Text Mask for VAT identification number
- Host: GitHub
- URL: https://github.com/dimitrinicolas/text-mask-vat-id
- Owner: dimitrinicolas
- License: mit
- Created: 2019-03-10T18:00:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-11T02:51:12.000Z (almost 5 years ago)
- Last Synced: 2025-04-10T11:48:31.332Z (6 months ago)
- Topics: text-mask, tva, vat
- Language: JavaScript
- Homepage: https://dimitrinicolas.github.io/text-mask-vat-id/example/
- Size: 596 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# text-mask-vat-id [![Build Status][travis badge]][travis link] [![Coverage Status][coveralls badge]][coveralls link]
Text Mask function for VAT identification number.
## [Example](https://dimitrinicolas.github.io/text-mask-vat-id/example/)
Demo available here: [dimitrinicolas.github.io/text-mask-vat-id/example](https://dimitrinicolas.github.io/text-mask-vat-id/example/)
## Installation
```bash
npm i text-mask-vat-id
```## Usage
I recommend you to add an uppercase pipe function to text-mask component:
```js
function upperCasePipe(value) {
return value.toUpperCase();
}
```### With React.js
```jsx
import React from 'react'
import MaskedInput from 'react-text-mask'
import createVatIdMask from 'text-mask-vat-id';const mask = createVatIdMask();
export default () => (
value.toUpperCase()} />
);
```### In Vanilla JS
```html
function upperCasePipe(value) {
return value.toUpperCase();
}vanillaTextMask.maskInput({
inputElement: document.getElementById('vat-input'),
mask: createVatIdMask(),
pipe: upperCasePipe
});
});```
## Options
You can pass options as an object when creating text mask:
```js
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:
```console
npm run build
```Build and test:
```console
npm test
```## Source
- [en.wikipedia.org/wiki/VAT_identification_number](https://en.wikipedia.org/wiki/VAT_identification_number)
- [www.gov.uk/guidance/vat-eu-country-codes-vat-numbers-and-vat-in-other-languages](https://www.gov.uk/guidance/vat-eu-country-codes-vat-numbers-and-vat-in-other-languages)## Related
- [`text-mask`](https://github.com/text-mask/text-mask) - Input mask for React, Angular, Ember, Vue, & plain JavaScript
## License
This project is licensed under the [MIT license](LICENSE).
[travis badge]: https://travis-ci.org/dimitrinicolas/text-mask-vat-id.svg?branch=master
[travis link]: https://travis-ci.org/dimitrinicolas/text-mask-vat-id
[coveralls badge]: https://coveralls.io/repos/github/dimitrinicolas/text-mask-vat-id/badge.svg?branch=master
[coveralls link]: https://coveralls.io/github/dimitrinicolas/text-mask-vat-id?branch=master