Registry / ecommerce / jquery-price-format

jquery-price-format

JSON →
library0.0.1jsnpmunverified

jQuery Price Format Plugin v0.0.1 formats input fields and HTML elements as currency values (e.g., 123456 becomes US$ 1,234.56). It offers customizable options: prefix, suffix, thousands separator, cents separator, clear prefix/suffix on blur, negative values, plus sign, and an unmask function. Released under MIT license. The package is a jQuery plugin with no active updates; similar functionality is available via native JavaScript Intl.NumberFormat.

npm install jquery-price-format
INSTALL
IMPORT
SIG · JQUERY-PRICE-FORMA
J
jquery-price-format
ecommercejavascriptv0.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

$.fn.priceFormat
$('#myInput').priceFormat(options); // Requires jQuery loaded globally
const pf = require('jquery-price-format'); // jQuery plugin cannot be required as module
This is a jQuery plugin. It must be loaded after jQuery via <script> tag or bundled. No ESM export.
unmask
var value = $('#myInput').unmask(); // Returns numeric string without formatting
var value = $('#myInput').unmask(); // Unmask is a method, not a property
unmask() is a jQuery method on the element after priceFormat() is called.
priceFormat (as a module)
// No import; use script tag: <script src='jquery-price-format.js'></script>
import priceFormat from 'jquery-price-format'; // Not a module
No ES or CommonJS module available. Only works in browser with global jQuery.

Demonstrates loading jQuery and the plugin via script tags, then applying priceFormat to an input with custom prefix and separators, and using unmask to get raw value.

<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="path/to/jquery.priceformat.js"></script> </head> <body> <input type="text" id="priceInput" value="123456"> <script> $('#priceInput').priceFormat({ prefix: 'US$ ', centsSeparator: '.', thousandsSeparator: ',' }); // On page load, input shows 'US$ 1,234.56' console.log($('#priceInput').val()); // 'US$ 1,234.56' console.log($('#priceInput').unmask()); // '123456' </script> </body> </html>
Debug
Known issues
gotchaPlugin requires jQuery globally. Ensure jQuery is loaded before the plugin script.
fix
Load jQuery via <script> tag before the plugin script.
affects: *
deprecatedNo longer maintained. Last update 2016. Similar functionality available via native JavaScript Intl.NumberFormat.
fix
Consider using Intl.NumberFormat or a modern formatting library.
affects: *
gotchaOptions 'clearPrefix' and 'clearSuffix' only work on blur; they do not affect display on focus.
fix
Set clearPrefix: true to hide prefix during editing; note that it only clears on blur.
affects: *
Errors
Common errors & fixes
$(...).priceFormat is not a function
jQuery or plugin not loaded before usage; or jQuery is not in global scope.
fix
Ensure jQuery is loaded and the plugin script is included after jQuery.
jQuery is not defined
jQuery library missing or loaded after the plugin script.
fix
Include jQuery before any plugin scripts: <script src='jquery.js'></script>
Cannot read property 'priceFormat' of undefined
Element selector returns no elements or jQuery is not loaded.
fix
Verify element exists and jQuery is loaded.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
jqueryrequiredPlugin extends jQuery.fn; requires jQuery to be loaded first.
Agent activity
26 hits · last 30 days
node
24
Resources
jquery-price-format — npm install jquery-price-format · libregistry