admin管理员组文章数量:1023546
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 );
});
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 );
});
本文标签:
版权声明:本文标题:html - Using an onblur event to send value to javascript function that will add .00 if it doesnt exist - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745539218a2155102.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论