herdofturtles21 herdofturtles21 - 2 months ago 10
HTML Question

Using an onblur event to send value to javascript function that will add .00 if it doesnt exist

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


Something like this:


<input placeholder="Amount" onblur="this.value=parseFloat(this.value).toFixed(2);" >