From what I understand of onblur, it calls an event when you click out of the textbox. I have a text box where users an enter a value the want to pay.
<input id='Line Item' type="text" placeholder="Amount" name="AmountPaying" class="field m w-input" value="" >
From what I understand of onblur, it calls an event when you click out of the textbox. I have a text box where users an enter a value the want to pay.
<input id='Line Item' type="text" placeholder="Amount" name="AmountPaying" class="field m w-input" value="" >
If they enter a 1.1 and click out of the box, I want it to change the value to 1.10, Or 1 to 1.00
Share Improve this question asked Aug 3, 2016 at 21:49 jreed21jreed21 751 gold badge1 silver badge7 bronze badges 02 Answers
Reset to default 7Something like this:
onblur="this.value=parseFloat(this.value).toFixed(2);"
<input placeholder="Amount" onblur="this.value=parseFloat(this.value).toFixed(2);" >
In your script file
document.querySelector('input[name="AmountPaying"]').addEventListener('blur', function() {
this.value = parseFloat( this.value ).toFixed( 2 );
});