https://github.com/dereke/format-input
Format the contents of an input element
https://github.com/dereke/format-input
Last synced: 10 months ago
JSON representation
Format the contents of an input element
- Host: GitHub
- URL: https://github.com/dereke/format-input
- Owner: dereke
- Created: 2015-11-09T19:07:18.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-09T23:40:01.000Z (about 10 years ago)
- Last Synced: 2025-02-18T14:51:55.292Z (10 months ago)
- Language: JavaScript
- Size: 0 Bytes
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Format Input
Format user input as a date/credit card/etc.
```bash
npm install format-input --save
```
# example
```js
var formatInput = require('format-input');
formatInput(document.getElementById('#date-of-birth'), 'cc/cc/cccc');
```
Now enter the date `19/05/1985`
When you type `190` it will be reformatted to `19/0`
as you continue it will be reformatted until it reaches the end of the given format.
You can also supply a different separator, in fact you can use any character except for the placeholder which defaults to `c` if this conflicts with your format (or you just don't like the letter 'c' then you can change the placeholder to something else, like `!`. `formatInput(element, '!!:!!, '!')`