Easy Number Separator is a useful pure JavaScript plugin for currency format and separate numbers on input.
- Separate numbers by your custom character separators like comma character (
,
) or any other characters. - Does not accept non-numeric characters.
- Can work on any text inputs by your selector.
- Add Easy Number Separator plugin to your project:
<script src="js/easy-number-separator.js"></script>
- Make your input text field like this:
<input type="text" class="number-separator" />
- Select your input element:
easyNumberSeparator({
selector: '.number-separator',
separator: ','
})
Title | Default | Description |
---|---|---|
selector | .number-separator |
Selects the input element |
separator | , |
The character of number separator |
decimalSeparator | . |
The character of decimal separator |
resultInput | - | Raw number generated for purposes such as server submission and calculations |
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',
})
<script src="https://cdn.jsdelivr.net/gh/amiryxe/easy-number-separator/easy-number-separator.js"></script>
Enjoy :)