这是我对电子邮件地址的表单验证 - 字段email1 - 我需要做的是添加第二个验证 - email1等于email2,如果没有,则显示不同的警报消息。我试着添加:
if (f.email1.value != f.email2.value)
{
customAlert ("email2",bnadd_msg_005);
return (false);
}
但这对我不起作用。有什么见解吗?
case "email1":
// Checking to make sure email field is on the form
if (typeof f.email1 != "undefined")
{
if ((f.email1.value == "") && (f.sameAsShip.checked) )
{
customAlert ("email1",bnadd_msg_018);
if ((typeof TeaLeaf != "undefined") && (typeof TeaLeaf.Client != "undefined") && (typeof TeaLeaf.Client.tlAddEvent != "undefined") ) {
var nVO = { ErrorMessage : bnadd_msg_018}
TeaLeaf.Event.tlAddCustomEvent(subtype, nVO);
}
return false;
}
//Validate that email address has @ and .
if(f.email1 && ( f.email1.value != "" ) && (!editEmail(f.email1.value,'Email Address')))
{
return false;
}
if(addrType == atBill)
{
if(f.email1.value == "")
{
customAlert ("email1",bnadd_msg_018);
if ((typeof TeaLeaf != "undefined") && (typeof TeaLeaf.Client != "undefined") && (typeof TeaLeaf.Client.tlAddEvent != "undefined") ) {
var nVO = { ErrorMessage : bnadd_msg_018}
TeaLeaf.Event.tlAddCustomEvent(subtype, nVO);
}
return false;
}
else
{
if(f.email1 && ( f.email1.value != "" ) && (!editEmail(f.email1.value,'Email Address')))
{
return false;
}
else
return true;
}
}
}
break;
答案 0 :(得分:0)
工作。感谢先前问题的帮助。
case "email2":
// Checking to make sure email field is on the form
if (typeof f.email2 != "undefined")
{
if ((f.email2.value != f.email1.value) && (f.sameAsShip.checked) )
{
customAlert ("email2",bnadd_msg_005);
if ((typeof TeaLeaf != "undefined") && (typeof TeaLeaf.Client != "undefined") && (typeof TeaLeaf.Client.tlAddEvent != "undefined") ) {
var nVO = { ErrorMessage : bnadd_msg_018}
TeaLeaf.Event.tlAddCustomEvent(subtype, nVO);
}
return false;
}
//Validate that email address has @ and .
if(f.email2 && ( f.email2.value != f.email1.value) && (!editEmail(f.email2.value,'Email Address')))
{
return false;
}
if(addrType == atBill)
{
if(f.email2.value != f.email1.value)
{
customAlert ("email2",bnadd_msg_005);
if ((typeof TeaLeaf != "undefined") && (typeof TeaLeaf.Client != "undefined") && (typeof TeaLeaf.Client.tlAddEvent != "undefined") ) {
var nVO = { ErrorMessage : bnadd_msg_005}
TeaLeaf.Event.tlAddCustomEvent(subtype, nVO);
}
return false;
}
else
{
if(f.email2 && (f.email2.value != f.email1.value) && (!editEmail(f.email1.value,'Email Address')))
{
return false;
}
else
return true;
}
}
}
break;