0.5.0 • Published 9 years ago
delimited-input v0.5.0
delimited-input
Proof-of-concept
Reading long numbers or codes is hard without some kind of delimiter to provide pacing or idea of the scale. This library provides support for formatting user input as it's written.
This library is fairly early in development but it should provide some basic support for formatting rules already.
Example input and output
- Big number: writing
7283947shows like this7,283,947 - Credit card: writing
4265827561095863shows like this4265 8275 6109 5863 - Product code: writing
abj39lv2jvk3show like thisabj3-9lv2-jvk3
Test at the project homepage.
Example usage
Auto-format user input as it is modified:
<input id="numeric_input" type="text" value="7,283,947"/>var thousandsDelimiter = DelimitedInput(",", 3);
document
.getElementById("numeric_input")
.addEventListener("keydown", thousandsDelimiter);Node
var DelimitedInput = require("delimited-input");RequireJS
requirejs(["delimited-input"], function(DelimitedInput) {
/*...*/
});Installing
npm install --save delimited-inputDevelopment
npm install
npm startOpen test.html in the browser (e.g. file://... from file system) for
testing. Code changes reload the test page automatically.