amiryxe / easy-number-separator

Easy Number Separator is a plugin for live separate input numbers in textboxes

Home Page:https://amiryxe.github.io/easy-number-separator/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 :)

About

Easy Number Separator is a plugin for live separate input numbers in textboxes

https://amiryxe.github.io/easy-number-separator/


Languages

Language:HTML 58.4%Language:JavaScript 41.6%