How to format price using jQuery

Formatting and validating price input text fields are common. One need to write code for formatting as well as for validating. But in today's post, You will find a jQuery plugin which can solves your problem. You don't have to do any kind of validation or formatting. The plugin will take care of everything.

jQuery Price Format is a plugin to format input text fields as prices. For example, if you type 123456, the plugin updates it to US$ 1,234.56. It is costumizable, so you can use other prefixes and separators (for example, use it to get R$ 1.234,55).


How to use it?


Download the plugin library and include its reference along with jQuery library.

Basic usage
$('#txtPrice').priceFormat();
With some customization
$('#txtPrice1').priceFormat({
    prefix: 'R$ ',
    centsSeparator: ',',
    thousandsSeparator: '.'
});
See result below.


Feel free to contact me for any help related to jQuery, I will gladly help you.
SHARE

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..