Skip to content

amiryxe/easy-number-separator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 

Repository files navigation

Easy Number Separator

Easy Number Separator is a useful pure JavaScript plugin for currency format and separate numbers on input.

Features

  • 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.

How to Use

  1. Add Easy Number Separator plugin to your project:
<script src="js/easy-number-separator.js"></script>
  1. Make your input text field like this:
<input type="text" class="number-separator" />
  1. Select your input element:
easyNumberSeparator({
    selector: '.number-separator',
    separator: ','
})

Options

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

Send data to server

If you want to send pure data to the server (without symbols), you can set a result input by resultInput property and hold the original value.

Example:

HTML:
<input type="text" id="result_input" name="">
JavaScript:
easyNumberSeparator({
    selector: '.number-separator',
    separator: ',',
    resultInput: '#result_input',
})

CDN

<script src="https://cdn.jsdelivr.net/gh/amiryxe/easy-number-separator/easy-number-separator.js"></script>

Enjoy :)