如何在JavaScript中计算四个文本框的总值 [英] How to calculate thetotal value of a four text box in javascript
本文介绍了如何在JavaScript中计算四个文本框的总值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序中有四个文本框,我想检查四个文本框的总数是否等于100.如果它小于或大于一百,我想通过错误来告知客户.应该在javascript的keyUp或文本更改事件中完成.如何执行.
在Advance中致谢
Hi,
I am having four text boxes in my application I want to check whether the total of the four text boxes should be equal to hundred. If it is less than and greater than hundred I want to through the error to the customer. It should be done in the keyUp or text change event using javascript. How to do this .
Thanks in Advance
推荐答案
将class ="calculate"添加到您的4个文本框中
add class="calculate" to your 4 textboxes
(' .calculate' span()(' keyup', function (){ var sum = 0 ;
('.calculate').on('keyup', function(){ var sum = 0;
(.calculate').each( parseFloat (
('.calculate').each(function(){ sum += parseFloat(
这篇关于如何在JavaScript中计算四个文本框的总值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文