添加验证两个文本框的值不能同时为零 [英] add validation two text box value cannot be zero at the same time

查看:46
本文介绍了添加验证两个文本框的值不能同时为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
i希望在两个文本框中添加一个验证,其中只有一个可以为零,两者都不能同时为零。

解决方案

您好,



试试这个



功能检查(){

var validate_result = true;

if(document.getElementById(<%= txt1.ClientID%>)。value == 0&& document.getElementById(< ;%= txt2.ClientID%>)。value == 0){

alert(''显示消息'');

validate_result = false;

}



}



try-> ;



if(textbox1.text ==0OR textbox2.text ==0)

{

//如果任一方框中包含0

}

其他

{

//如果框中没有任何一个将包含0

//执行你想要的东西

}


  if (textbox1.Text ==   0 &安培;&安培; textbox2.Text ==   0
{
// 错误
}
else
{
// 写一些代码
}


hi i want to add a validation to two text box that only one of them can be zero,both of them cannot be zero at the same time.

解决方案

Hi,

Try this

function check() {
var validate_result = true;
if (document.getElementById("<%=txt1.ClientID%>").value == 0 && document.getElementById("<%=txt2.ClientID%>").value == 0) {
alert(''Display message'');
validate_result = false;
}

}


try->

if(textbox1.text=="0" OR textbox2.text=="0")
{
//This block will execute if either box contain "0"
}
else
{
//If none of box will contain "0"
//Execute what u want
}


if(textbox1.Text=="0" && textbox2.Text=="0")
{
// error
}
else
{
//write some code
}


这篇关于添加验证两个文本框的值不能同时为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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