credit-card-space

1.4.2 • Public • Published

semantic-release

Credit Card Space

Formats input with a space after every 4 digits. Unlike other credit card number formatters it respects card numbers more then 16 digits.

You can set any split pattern with data-pattern input attribute. '4 4 4 4' is default pattern.

Usage

As module

import CreditCardSpace from 'credit-card-space';
 
const input = document.querySelector('#card_number');
const ccSpace = new CreditCardSpace(input);
 
const cardNumber = ccSpace.value();

In browser

Add link into your page:

<script src="node_modules/credit-card-space/dist/credit-card-space.min.js"></script>
<input data-pattern="4 2 2 2 2 4">

You've got global CreditCardSpace constructor:

var input = document.querySelector('input');
var ccInput = new CreditCardSpace(input);

Try it on test page

Readme

Keywords

Package Sidebar

Install

npm i credit-card-space

Weekly Downloads

24

Version

1.4.2

License

MIT

Unpacked Size

80.7 kB

Total Files

22

Last publish

Collaborators

  • konclave