日期:2014-05-18  浏览次数:20730 次

新手提问:js返回false了,怎么页面继续运行??
如下是一个写邮件页面,什么都不添点击 "发送 "后,弹出 "发件人 "不能空,点 "确定 "后,本来应该是把光标放在 "发件人 "着,可他竟然跑到form中指定的action= "sendMail.jsp "这个页面了,大虾求助:
--------------------
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 发邮件 </title>
<script   language= "javascript ">
function   InputCtrl(type)
{
var   link=document.getElementById(type);

if(type== "acc ")
{
link.style.display= "none ";
document.getElementById( 'dcc ').style.display= " ";
document.getElementById( 'cc ').style.display= " ";
}
if(type== "dcc ")
{
link.style.display= "none ";
document.getElementById( 'acc ').style.display= " ";
document.getElementById( 'cc ').style.display= "none ";
}
if(type== "abcc ")
{
link.style.display= "none ";
document.getElementById( "dbcc ").style.display= " ";
document.getElementById( "bcc ").style.display= " ";
}
if(type== "dbcc ")
{
link.style.display= "none ";
document.getElementById( "abcc ").style.display= " ";
document.getElementById( "bcc ").style.display= "none ";
}
}
function   checkForm()
{
var   receiver=form1.tf_receiver.value;
var   cc=form1.tf_Cc.value;
var   bcc=form1.tf_Bcc.value;
var   subject=form1.tf_subject.value;
//var   err=document.getElementById( "err ");
if(receiver.length> 0)
{
isEmails(receiver, "tf_recevier ", "收件人电子邮件格式不合法! ");
}
else
{
alert( "收件人不能空! ");
//err.innerHtml   =   "收件人不能空 ";
form1.receiver.focus();
return   false;
//keepState();
}
if(cc.length> 0)
{
isEmails(cc, "tf_cc ", "抄送人电子邮件格式不合法! ");
}
if(bcc.length> 0)
{
isEmails(bcc, "tf_bcc ", "密送人电子邮件格式不合法! ");
}
return   true;
}

function   isEmails(str,tab,err)
{
if(str.indexOf( ", ")==-1)
{
if(!isEmail(str))
{
alert(err);
form1.tab.focus();
return   false;
}
}
else
{
var   flag=0;
var   strArray=new   Array();
strArray=str.split( ", ");
for(i=0;i <strArray.length;i++)
{
if(!isEmail(strArray[i]))
{
flag++;
}
}
if(flag!=0)
{
alert(err);
form1.tab.focus();
return   false;
}
}
}

</script>
</head>