Minimal jQuery Price Input Format Plugin - Price Format

Minimal jQuery Price Input Format Plugin - Price Format
File Size: 9.89 KB
Views Total: 3055
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A simplist jQuery number format plugin used to format input text fields as prices with custom decimal separator and thousands separator. For example, if you type 123456, the plugin updates it to 1,234.56.

How to use it:

1. Include jQuery library and the jQuery price format plugin before closing body tag.

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="jquery.priceformat.js"></script>

2. Create a standard text field that will only accepts number input.

<input id="price" type="text">

3. Call the plugin with customzation options.

$(document).ready(function () {
$('#price').priceformat({
  defaultValue: 0,
  decimalSeparator: '.',
  thousandsSeparator: ','
});
})

4. You can also pass the options to the price input by using data-OPTION attributes as follows.

<input id="price" type="text" data-format="price" value="0" data-thousands-separator=",">

Change log:

2014-10-01

  • v1.0.2

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