Easy Number Separator For Currency Input

Category: Form , Javascript | November 21, 2021
Author:amiryxe
Views Total:25 views
Official Page:Go to website
Last Update:November 21, 2021
License:MIT

Preview:

Easy Number Separator For Currency Input

Description:

A really 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',
})

Changelog:

11/21/2021

  • fix: run separator on phone keyboards

10/19/2021

  • create result input to hold original value

10/08/2021

  • JS Update

You Might Be Interested In:


Leave a Reply