jQuery Plugin For Number Input Formatting - Mask Number

File Size: 6.82 KB
Views Total: 52500
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin For Number Input Formatting - Mask Number

Mask Number is a small and easy-to-use jQuery plugin that automatically restricts, masks and formats decimal / integer numbers numbers in a specific pattern as you type on input fields. With support for custom decimal and thousands separators. Works both on desktop and mobile devices. Ideal for currency, and integer number input.

How to use it:

1. Load the jQuery mask number plugin after you first have jQuery library have loaded.

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="jquery.masknumber.js"></script>

2. Initialize the plugin with default options. Just call the function on the input field and we're done.

$('input').maskNumber();

3. Change the default decimal separator by passing the 'decimal' option on init.

$('input').maskNumber({
  decimal: '_'
});

4. Change the default thousands separator by passing the 'thousands' option on init.

$('input').maskNumber({
  thousands: '*'
});

5. Config the plugin to allow integer numbers.

$('input').maskNumber({
  integer: true,
});

Changelog:

2019-03-12

  • Allow Negative Numbers

This awesome jQuery plugin is developed by normandesjr. For more Advanced Usages, please check the demo page or visit the official website.