herdofturtles21 herdofturtles21 - 1 year ago 73
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

Answer Source

Something like this:


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download