如下是一个写邮件页面,什么都不添点击"发送"后,弹出"发件人"不能空,点"确定"后,本来应该是把光标放在"发件人"着,可他竟然跑到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><body>
<form action="sendMail.jsp" method="post" name="form1" id="form1">
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25"><label>
<input name="send" type="submit" id="send" value="发送" onClick="javascript:return checkForm()" />
</label>
<label>
<input name="save" type="submit" id="save" value="存草稿" />
<input name="cancle" type="submit" id="cancle" value="关闭" />
</label>
<div id="err"></div>
</td>
</tr>
</table>
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80" height="20"> </td>
<td><a id="acc" href="#" onClick="javascript:InputCtrl('acc')">添加抄送</a><a id="dcc" href="#" onClick="javascript:InputCtrl('dcc')" style="display:none">删除抄送</a>
|
<a id="abcc" href="#" onClick="javascript:InputCtrl('abcc')">添加密送</a><a id="dbcc" href="#" onClick="javascript:InputCtrl('dbcc')" style="display:none">删除密送</a>
</td>
</tr>
</table> <table width="780" border="0" cellpadding="0" cellspacing="0" id="sender">
<tr>
<td width="80" height="20">收件人</td>
<td><label>
<input name="tf_receiver" type="text" id="tf_receiver" size="80" />
</label></td>
</tr>
</table>
<table width="780" border="0" cellspacing="0" cellpadding="0" style="display:none" id="cc">
<tr>
<td width="80">抄 送</td>
<td><label><input name="tf_Cc" type="text" id="tf_Cc" size="80" /></label></td>
</tr>
</table>
<table width="780" border="0" cellspacing="0" cellpadding="0" style="display:none" id="bcc">
<tr>
<td width="80">暗 送</td>
<td><label><input name="tf_Bcc" type="text" id="tf_Bcc" size="80" /></label></td>
</tr>
</table>
<table width="780" border="0" cellpadding="0" cellspacing="0" id="subject">
<tr>
<td width="80" height="20">主 题</td>
<td><label><input name="tf_subject" type="text" id="tf_subject" size="80" /></label></td>
</tr>
</table>
<table width="780" border="0" cellpadding="0" cellspacing="0" id="attaches">
<tr>
<td width="80">附 件</td>
<td><label>
<input name="attach" type="file" size="50" />
移除附件<br />
增加附件</label></td>
</tr>
</table>
<table width="780" border="0" cellpadding="0" cellspacing="0" id="content">
<tr>
<td width="80" valign="top">正 文</td>
<td><label>
<textarea name="tf_content" cols="80" rows="20" id="tf_content"></textarea>
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input name="ck_reply" type="checkbox" id="cb_reply" value="checkbox" />
需要回执
<input name="ck_alarm" type="checkbox" id="ck_alarm" value="checkbox" />
紧急</label></td>
</tr>
</table> <table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25"><label>
<input name="send2" type="submit" id="send2" value="发送" onClick="javascript:return checkForm()"/>
</label>
<label>
<input name="save2" type="submit" id="save2" value="存草稿" />
<input name="cancle2" type="submit" id="cancle2" value="关闭" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
--------------------------------------------------------
<%@ 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><body>
<form action="sendMail.jsp" method="post" name="form1" id="form1">
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25"><label>
<input name="send" type="submit" id="send" value="发送" onClick="javascript:return checkForm()" />
</label>
<label>
<input name="save" type="submit" id="save" value="存草稿" />
<input name="cancle" type="submit" id="cancle" value="关闭" />
</label>
<div id="err"></div>
</td>
</tr>
</table>
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80" height="20"> </td>
<td><a id="acc" href="#" onClick="javascript:InputCtrl('acc')">添加抄送</a><a id="dcc" href="#" onClick="javascript:InputCtrl('dcc')" style="display:none">删除抄送</a>
|
<a id="abcc" href="#" onClick="javascript:InputCtrl('abcc')">添加密送</a><a id="dbcc" href="#" onClick="javascript:InputCtrl('dbcc')" style="display:none">删除密送</a>
</td>
</tr>
</table> <table width="780" border="0" cellpadding="0" cellspacing="0" id="sender">
<tr>
<td width="80" height="20">收件人</td>
<td><label>
<input name="tf_receiver" type="text" id="tf_receiver" size="80" />
</label></td>
</tr>
</table>
<table width="780" border="0" cellspacing="0" cellpadding="0" style="display:none" id="cc">
<tr>
<td width="80">抄 送</td>
<td><label><input name="tf_Cc" type="text" id="tf_Cc" size="80" /></label></td>
</tr>
</table>
<table width="780" border="0" cellspacing="0" cellpadding="0" style="display:none" id="bcc">
<tr>
<td width="80">暗 送</td>
<td><label><input name="tf_Bcc" type="text" id="tf_Bcc" size="80" /></label></td>
</tr>
</table>
<table width="780" border="0" cellpadding="0" cellspacing="0" id="subject">
<tr>
<td width="80" height="20">主 题</td>
<td><label><input name="tf_subject" type="text" id="tf_subject" size="80" /></label></td>
</tr>
</table>
<table width="780" border="0" cellpadding="0" cellspacing="0" id="attaches">
<tr>
<td width="80">附 件</td>
<td><label>
<input name="attach" type="file" size="50" />
移除附件<br />
增加附件</label></td>
</tr>
</table>
<table width="780" border="0" cellpadding="0" cellspacing="0" id="content">
<tr>
<td width="80" valign="top">正 文</td>
<td><label>
<textarea name="tf_content" cols="80" rows="20" id="tf_content"></textarea>
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input name="ck_reply" type="checkbox" id="cb_reply" value="checkbox" />
需要回执
<input name="ck_alarm" type="checkbox" id="ck_alarm" value="checkbox" />
紧急</label></td>
</tr>
</table> <table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25"><label>
<input name="send2" type="submit" id="send2" value="发送" onClick="javascript:return checkForm()"/>
</label>
<label>
<input name="save2" type="submit" id="save2" value="存草稿" />
<input name="cancle2" type="submit" id="cancle2" value="关闭" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
解决方案 »
- java类中jdbc调用存储过程?存储过程在oracle里又是怎么建立的?
- java List分组问题
- 可以吧,某个网站整个下载下来改成自己的网站么
- 请问以下错误是在tomcat中运行时出现的,该如何解决?
- 求一个网上书店的数据库设计?? [email protected]
- 课本上的一段JSP代码,我这边无法执行,求改错
- 那位兄弟有<<How Tomcat Works>>这本书呀,或者知道那里可以下载呀
- 刚学jsp,觉的jsp没有php快,没有asp简单,没有.net强大,我们为什么还要学习jsp?谁可以告诉我?
- post提交后,返回结果乱码。能搜到的解决方法都用了,不管用。
- j_security_check对应的后台路径是什么
- jsp一般用什么做服务器
- 弱问tomcat的简单问题
还是会转到下一个页面,555.
该成return false看看;
改了还是一样,我以前都用return true;都可以的.这次莫名其妙了.
form1.tf_receiver.focus();肯定好了,你太粗心了
哎,真丢人啊.~~~~~~~~~~~~~~~~
你看的那么仔细,才给你10分,过意不去,以后补上 !!!