Custom Thousands Separator With jQuery - number-divider

File Size: 9.24 KB
Views Total: 11547
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Custom Thousands Separator With jQuery - number-divider

number-divider is a lightweight jQuery number formatting plugin that has the ability to divide numeric values with custom thousands separator and/or decimal separator.

How to use it:

1. Include both jQuery library and the jQuery number-divider plugin's script on the html page.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="number-divider.js"></script>

2. Wrap your numeric values into any container elements and even input fields as follow:

<div class="divide">20000</div>
<input type="text" class="divide" value="20000"></div>

3. Call the plugin's main function and done.

$('.divide').divide();

4. Customize the thousands separator.

$('.divide').divide({
  delimiter: ',',
  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.