JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" class="pr-dec" size="8" value="1000.00" />
CSS
/*
- User can use only numeric chars. Nothing else.
- User can't delete a dot. Never. Is it possible? If it isn't and the user will remove the dot, how to give the dot back automatically on losing focus?
- On blur (lose focus), if the decimal places are empty, script fill it with zeros.
- I need this pattern for view: X XXX.XX (toFixed(2) I can use for two decimal places, but I don't know way to separate string according pattern).
Certainly you've noticed, that the text field have to be the price. The script should operate on multiple input fields with class "pr-dec".
*/
input.pr-dec {
}
JavaScript
$('.pr-dec').live('blur', function() {
});