Quick and dirty currency formatter that ties into the currency format features in Laravel Currency.
Overriding the default currency format:
$.setCurrencyOptions({
defaultFormat: '1.0,00 €'
});
$.formatCurrency(:value, :format, :onlyNumbers)
Arguments
:value
- the float amount to convert:format
- the currency format (if empty the default value will be used):onlyNumbers
- when true it will return formatted value without the currency symbol
For real-time formatting of during a blur event trigger, use the data-format-currency
attribute.
Format the input using the default currency format:
<input type="text" name="price" placeholder="0.00" data-format-currency>
Override the default currency format:
<input type="text" name="price" placeholder="0.00" data-format-currency="₱1,0.00">