Auto Format Currency In Number Input - pcsFormatNumber

Auto Format Currency In Number Input - pcsFormatNumber
File Size: 4.52 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

pcsFormatNumber is a super tiny number formatting plugin that automatically formats currency (money) as you type on a number input.

Features:

  • Custom decimal separator.
  • Custom number separator.
  • Custom currency symbol

How to use it:

1. Link to jQuery library and the jQuery pcsFormatNumber plugin's script like this:

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="js/pcsFormatNumber.jquery.js"></script>

2. Attach the main function pcsFormatNumber() to the number input and done.

$('.myIput').pcsFormatNumber();

3. Customize the decimal/number separators.

$('.myIput').pcsFormatNumber({
  decimal_separator: ".",
  number_separator: ",",
});

4. Change the default currency symbol:

$('.myIput').pcsFormatNumber({
  currency: "€"
});

5. Set the number of decimal places:

$('.myIput').pcsFormatNumber({
  to_fixed: 2
});

This awesome jQuery plugin is developed by Pasquale-CS. For more Advanced Usages, please check the demo page or visit the official website.