
A simple JavaScript plugin that lets you format a number with a custom character (default: comma) as a thousands separator.
How to use it:
1. Import the easy-number-separator.js JavaScript library.
<script src="easy-number-separator.js"></script>
2. Attach the easyNumberSeparator to the input field you specify and done.
<input type="text" class="number-separator" placeholder="Enter Your Number..." />
easyNumberSeparator({
selector: '.number-separator',
})3. Customize the thousands separator. Default: comma(,).
easyNumberSeparator({
selector: '.number-separator',
separator: '.'
})4. If you want to send data to the server, you can set a result input by resultInput property and hold the original value.
<input type="text" id="result_input" name="">
easyNumberSeparator({
selector: '.number-separator',
separator: ',',
resultInput: '#result_input',
})5. More configuration options.
easyNumberSeparator({
// Maximum decimal places (0 = no decimals)
maxDecimals: 0,
// Adds a hidden input with the input's name holding the raw number, so forms submit it unformatted
submitRaw: false,
// Block pasting into the input
disallowPaste: false,
// Block dragging and dropping text into the input
disallowDrop: false,
})Changelog:
v1.1.0 (10/06/2026)
- Added more options
11/29/2022
- fix: fire separator on appended fields
06/22/2022
- fix bug in default configs and decimal separator
11/21/2021
- fix: run separator on phone keyboards
10/19/2021
- create result input to hold original value
10/08/2021
- JS Update







