jQuery Plugin For Custom Number Separator - Number Divider

jQuery Plugin For Custom Number Separator - Number Divider
File Size: 8.86 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Number Divider is a lightweight yet very useful jQuery plugin which allows to separate numeric values with custom characters (space, comma, dot or whatever you like). Useful for currency formatting and credit card input in your e-commerce website. Another use case is to print your number with custom characters as thousands separators on the webpage.

How to use it:

1. To install the Number Divider, just include the JavaScript file number-divider.min.js after jQuery library and we're ready to go.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="dist/number-divider.min.js"></script>

2. Apply the plugin to a text input field.

$('input').divide();

3. You're also allowed to divide numbers in HTML tags as follows:

<div class="divide">1000</div>
$(''.divide').divide();

4. Customize the delimiter.

$('input').divide({
  delimiter: ','
});

5. More plugin options.

$('input').divide({
  divideThousand: true, // 1,000..9,999
  delimiterRegExp: /[\.\,\s]/g
});

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