I do not need a mask, but I need something that will format currency(in all browsers) and not allow for any letters or special char's to be typed. Thanks for the help
Example:
Valid: $50.00
$1,000.53
Not Valid: $w45.00
$34.3r6
The jQuery Format plugin enables the formatting and parsing of dates and numbers. It's a client-side alternative of the popular SimpleDateFormat and NumberFormat APIs.
JavaScript numbers can be formatted in different ways like commas, currency, etc. You can use the toFixed() method to format the number with decimal points, and the toLocaleString() method to format the number with commas and Intl. NumberFormat() method to format the number with currency.
Another option (If you are using ASP.Net razor view) is, On your view you can do
<div>@String.Format("{0:C}", Model.total)</div>
This would format it correctly. note (item.total is double/decimal)
if in jQuery you can also use Regex
$(".totalSum").text('$' + parseFloat(total, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString());
JQUERY FORMATCURRENCY PLUGIN
http://code.google.com/p/jquery-formatcurrency/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With