我已经在html页面中添加了一些javascript输入validation.same页面在IE和Chrome中正常工作,但在mozila其不工作。问题是,当用户输入无效数据显示警报味精盒,当用户点击OK它应该返回假形成...... 但 mozila不是等着警告框它只是显示警告框5-6秒,然后进入到下一页中定义的form action =“nextpage.php”java脚本不工作在mozila
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(oldpassword, "<b>Error: </b>Please enter the Old Password!") == false)
{ changeColor("oldpassword"); return false; }
else if (valid_length(newpassword, "<b>Error: </b>Please enter the New Password!!") == false)
{newpassword.value=""; changeColor("newpassword"); return false; }
else if (valid_length(cnfpassword, "<b>Error: </b>Please enter the Confirm Password!!") == false)
{cnfpassword.value=""; changeColor("cnfpassword"); return false; }
else if (document.getElementById('newpassword').value != document.getElementById('cnfpassword').value)
{changeColor("newpassword");cool.error("<b>Error: </b>Passwords entered are not same!");
newpassword.value="";cnfpassword.value="";return false;}
}
}function validate_required(field, alerttxt)
{
with (field)
{
if (value == null || value == "")
{
cool.error(alerttxt);return false;
}
else
{
return true;
}
}
}
cool.error无非是CSS次的js警报box.I事情没有我代码天气问题的任何问题在一些浏览器settings.Is会这样???因为它工作正常IE和Chrome。
作为一般说明在这里,不要假设错误是**不在你的代码**,99.9999%的时间,至少在已建立的平台上,**它是你的代码**,假设相反将不会做任何事情但浪费时间找到原因。 – 2010-05-16 19:56:55
作为另一个不是你可能想看看一些jQuery验证插件可能会节省一些时间 – mcgrailm 2010-05-16 20:00:11