-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
436a07c
commit b87780e
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Simple Card | ||
|
||
Tiny library to help you with credit card inputs. | ||
|
||
## Installation | ||
|
||
### npm | ||
```bash | ||
npm i @invoiceninja/simple-card | ||
``` | ||
|
||
## Usage | ||
|
||
```html | ||
<form> | ||
<input | ||
type="text" | ||
name="number" | ||
placeholder="0000 0000 0000 0000" | ||
id="number" | ||
/> | ||
|
||
<input type="text" name="date" placeholder="mm/yy" id="date" /> | ||
<input type="text" name="number" placeholder="000" id="cvv" /> | ||
</form> | ||
``` | ||
|
||
```js | ||
const simpleCard = new SimpleCard({ | ||
fields: { | ||
card: { | ||
number: "#number", | ||
cvv: "#cvv", | ||
date: "#date", | ||
}, | ||
}, | ||
}).mount(); | ||
``` | ||
|
||
### Available methods | ||
|
||
#### Check if the fields are valid: | ||
```js | ||
simpleCard.check() | ||
``` | ||
|
||
#### Get the credit card type: | ||
```js | ||
simpleCard.type() // visa, mastercard .. or unknown. | ||
``` | ||
|
||
## Contributing | ||
|
||
### Requirements | ||
|
||
- Node.js 20.x | ||
|
||
You can start by cloning repository locally using git. | ||
|
||
```bash | ||
git clone https://github.com/invoiceninja/simple-card.git | ||
npm i | ||
npm run dev | ||
``` | ||
|
||
The demo is provided in demo.html available after starting the dev server (http://localhost:5173). | ||
|
||
## Licence | ||
The MIT License (MIT). |