你的程序是不是总是报错,即 ("您的生日填写有错误.");
如果是的话,我试了一下
你的else没有指定正确位置,即根据就近原则它和最后一个if配对
所以不管你的if后面的条件是否为真,都会执行
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
因为if 和else一样的
如果你有良好的编程习惯的话(缩进编辑,配对括号),你会很清楚
的发现问题所在。修改后如下(仅供参考)function checkForm(theForm)
{
if ((!theForm.dtBirthYearGet.value) && (!theForm.dtBirthMonthGet.value) && (!theForm.dtBirthDayGet.value))
{
if (!isNaN(theForm.dtBirthYearGet.value) && (!isNaN(theForm.dtBirthMonthGet.value) && (!isNaN(theForm.dtBirthDayGet.value))
{
if (((theForm.dtBirthYearGet.value <= 1900) ¦¦(theForm.dtBirthMonthGet.value >= 2002)) ¦¦ ((theForm.dtBirthMonthGet.value <=1) ¦¦ (theForm.dtBirthMonthGet.value >= 12)) ¦¦ ((theForm.dtBirthDayGet.value <= 1) ¦¦ (theForm.dtBirthDayGet.value >= 31)))
{
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
}
}
else
{
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
}
}
如果是的话,我试了一下
你的else没有指定正确位置,即根据就近原则它和最后一个if配对
所以不管你的if后面的条件是否为真,都会执行
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
因为if 和else一样的
如果你有良好的编程习惯的话(缩进编辑,配对括号),你会很清楚
的发现问题所在。修改后如下(仅供参考)function checkForm(theForm)
{
if ((!theForm.dtBirthYearGet.value) && (!theForm.dtBirthMonthGet.value) && (!theForm.dtBirthDayGet.value))
{
if (!isNaN(theForm.dtBirthYearGet.value) && (!isNaN(theForm.dtBirthMonthGet.value) && (!isNaN(theForm.dtBirthDayGet.value))
{
if (((theForm.dtBirthYearGet.value <= 1900) ¦¦(theForm.dtBirthMonthGet.value >= 2002)) ¦¦ ((theForm.dtBirthMonthGet.value <=1) ¦¦ (theForm.dtBirthMonthGet.value >= 12)) ¦¦ ((theForm.dtBirthDayGet.value <= 1) ¦¦ (theForm.dtBirthDayGet.value >= 31)))
{
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
}
}
else
{
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
}
}
如果是的话,我试了一下
你的else没有指定正确位置,即根据就近原则它和最后一个if配对
所以不管你的if后面的条件是否为真,都会执行
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
因为if 和else一样的
如果你有良好的编程习惯的话(缩进编辑,配对括号),你会很清楚
的发现问题所在。修改后如下(仅供参考)function checkForm(theForm)
{
if ((!theForm.dtBirthYearGet.value) && (!theForm.dtBirthMonthGet.value) && (!theForm.dtBirthDayGet.value))
{
if (!isNaN(theForm.dtBirthYearGet.value) && (!isNaN(theForm.dtBirthMonthGet.value) && (!isNaN(theForm.dtBirthDayGet.value))
{
if (((theForm.dtBirthYearGet.value <= 1900) ¦¦(theForm.dtBirthMonthGet.value >= 2002)) ¦¦ ((theForm.dtBirthMonthGet.value <=1) ¦¦ (theForm.dtBirthMonthGet.value >= 12)) ¦¦ ((theForm.dtBirthDayGet.value <= 1) ¦¦ (theForm.dtBirthDayGet.value >= 31)))
{
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
}
}
else
{
window.alert ("您的生日填写有错误.");
theForm.dtBirthYearGet.focus();
return(false);
}
}
}