我正在尝试在按钮上写一个验证声明,说如果两个特定的文本字段为空并且他们点击按钮,则返回消息“此字段有效”
以下是我目前的代码:
function validateButton(){
if (tfState.getValue()!=''){
if (tfCity.getValue()!='') return true;
else return 'This value is not valid.';
}
else return true;
}
答案 0 :(得分:0)
我不确定getValue();
是什么,但假设tfState
和tfCity
是对DOM节点的引用:
function validateButton(){
if (tfState.value !='' && tfCity.value != ''){
return true;
}
return 'This value is not valid.';
}
答案 1 :(得分:0)
这就是你想要的
function validateButton(){
if ((tfState.val().length != 0) && (tfCity.val().length != 0))
return true;
}
else return 'This value is not valid.';
}