var v4 = document.f1.address.value;
if(v4=="" || v4.trim().length==0)
{
valMessage('addressmsg','Please enter address');
document.f1.address.focus();
return false;
}
var v5 = document.f1.city.value;
if(v5=="" || v5.trim().length==0)
{
valMessage('citymsg','Please enter your city');
document.f1.city.focus();
return false;
}
function valMessage(divName, content) {
document.getElementById(divName).innerHTML = content;
}
更正后错误消息不会消失。该怎么办? html体中给出的除法ID不用担心
答案 0 :(得分:0)
您可以显示/隐藏您的divName元素,其中showDiv是一个布尔值(true / false):
function valMessage(divName, content, showDiv) {
document.getElementById(divName).style.visibility = showDiv ? "visible" : "hidden";
document.getElementById(divName).innerHTML = content;
}