Lightweight Pure JavaScript Input Mask

Category: Form , Javascript | January 9, 2015
Author: spyter
Views Total: 11,133
Official Page: Go to website
Last Update: January 9, 2015
License: MIT

Preview:

Lightweight Pure JavaScript Input Mask

Description:

A pure JavaScript library to make masks on input fields for better number entering like phone number, SSN, date & time , etc.

Basic Usage:

Import input-mask.js script into your document.

<script src="input-mask.js" ></script>

Make a mask for SSN input.

new InputMask().Initialize(document.querySelectorAll("#SSN"),{
  mask: InputMaskDefaultMask.Ssn, 
  placeHolder: "SSN: 999-99-9999" 
});

Make a mask for data/time input.

new InputMask().Initialize(document.querySelectorAll("#date"),{
  mask: InputMaskDefaultMask.Date, 
  placeHolder: "Date: 01/01/2015" 
});

Make a mask for  phone number input.

new InputMask().Initialize(document.querySelectorAll("#date"),{
  mask: InputMaskDefaultMask.Date, 
  placeHolder: "Date: 01/01/2015" 
});

You Might Be Interested In:


Leave a Reply