Skip to content

teijo/delimited-input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 7283947 shows like this 7,283,947
  • Credit card: writing 4265827561095863 shows like this 4265 8275 6109 5863
  • Product code: writing abj39lv2jvk3 show like this abj3-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-input

Development

npm install
npm start

Open test.html in the browser (e.g. file://... from file system) for testing. Code changes reload the test page automatically.

About

<input> field auto-formatter for large numbers, credit card numbers, codes, etc.

Resources

Stars

Watchers

Forks

Packages

No packages published