Re:JavaScript:我有4个文本框,其中3个是我们可以输入整数值的值,第4个文本框是只读的. [英] Re:JavaScript: I have 4 textboxes in that 3 are we can enter the integer Values 4 th textbox is read only.

查看:75
本文介绍了Re:JavaScript:我有4个文本框,其中3个是我们可以输入整数值的值,第4个文本框是只读的.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有4个ASP文本框,其中3个是我们可以输入整数值的值,第4个文本框是只读的.
例如,在第一个文本框中,他们输入的值为20.
然后第二个文本框在这种情况下最多允许20个,其余两个文本框我需要预填充0(零).
在第二种情况下,可以输入的第二个文本框的值是15,第三个文本框的值是3,然后
第四个文本框应预填其余的"2".
最后,三个(2nd,3rd,4th)文本框值的总和应与第一个texbox值相匹配...........
请帮助我任何一个..

Hi I have 4 asp textboxes in that 3 are we can enter the integer Values 4 th textbox is read only.
For example In 1st Textbox they entered the value is 20.
then 2nd textbox allow up to 20 at this case remaining two textboxes i need to prepopulate 0(Zero).
In second case the can enter 2 nd textbox vlaue is 15 3rd textbox value is 3 then
4 th textbox should prepoulate remaing ''2''.
finally the sum of three(2nd,3rd,4th)textboxes values should match with 1st texbox value ...........
Please help me any one ..

推荐答案

您可以使用以下javascript函数:

You can use following javascript function:

function Matchvalues()
{
  var value1 = document.getElementById('TextBox1').value;
  var value2 = parseInt(document.getElementById('TextBox2').value) +
               parseInt(document.getElementById('TextBox3').value) +
               parseInt(document.getElementById('TextBox4').value);

  if (value1 != value2) {
    alert('value in 1st TextBox and sum of Textbox2,Textbox3,Textbox4 are not matched');
    return false;
  }
  else {
    alert('value in 1st TextBox and sum of Textbox2,Textbox3,Textbox4 are matched');
    return true;
  }

}



在按钮的OnClientClick事件上调用此函数.

问候,
Bhushan Shah



call this function on OnClientClick event of a button.

Regards,
Bhushan Shah


这篇关于Re:JavaScript:我有4个文本框,其中3个是我们可以输入整数值的值,第4个文本框是只读的.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆