js 的 提交

扫码查看
<script type="text/javascript">
function sub(){
if(document.form1.xingming.value=="") {
alert("姓名不能为空!");
form1.xingming.focus();
return false;
}
if(document.form1.mail.value=="") {
alert("请输入邮箱");
form1.mail.focus();
return false;
}
else{
var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if(!reg.test(document.form1.mail.value)){
alert("邮箱格式不正确!");
form1.mail.focus();
return false;
}
}
if(document.form1.liuyan.value=="") {
alert("请输入留言标题");
form1.liuyan.focus();
return false;
}
if(document.form1.neirong.value=="") {
alert("请输入留言内容");
form1.neirong.focus();
return false;
} document.form1.action="/跳转地址";
document.form1.submit();
} </script>

以上是js代码

以下是界面                           
<div class="letterMain">
<form action="/zykj_tl/wyzx.zykj" method="post" name="form1" id="form1">
<table class="letterMainTable">
<tr>
<td width="90" height="40" align="center" bgcolor="f3f3f3">姓 名:</td>
<td height="40" width="269" align="left"><input type="text" name="xingming" id="xingming" maxlength="10"/><span class="redFont" style="position:relative;*top:-4px;">*</span></td>
<td width="90" height="40" align="center" bgcolor="f3f3f3">E-mail:</td>
<td height="40" align="left"><input type="text" name="mail" id="mail" maxlength="40"/></td>
</tr>
<tr>
<td height="40" align="center" bgcolor="f3f3f3">地址:</td>
<td height="40" align="left"><input type="text" name="dizhi" id="dizhi" maxlength="50"/></td>
<td height="40" align="center" bgcolor="f3f3f3">QQ号码:</td>
<td height="40" align="left"><input type="text" name="qq" id="qq" maxlength="20"/></td>
</tr>
<tr>
<td height="40" align="center" bgcolor="f3f3f3">留言主题:</td>
<td height="40" align="left" colspan="3"><input type="text" style="width:551px;" name="liuyan" id="liuyan" maxlength="50"/><span class="redFont" style="position:relative;*top:-4px;">*</span></td>
</tr>
<tr>
<td height="178" align="center" bgcolor="f3f3f3">内 容</td>
<td height="178" align="left" colspan="3"><textarea style="width:551px;height:160px;" name="neirong" id="neirong"></textarea><span class="redFont" style="position:relative;top:-67px;*top:-71px;">*</span></td>
</tr> </table> <tr>
<td height="70" align="center" colspan="4">
<!-- <a href="###" class="surveySubmit" style="margin-left:226px;">提 交</a>
<a href="###" class="surveyView">重 置</a> -->
<input type="button" name="button" class="surveySubmit" onclick="sub()" style="margin-left:226px;margin-top:30px;" value="提交" style="border:0px;">
<input type="button" name="button" class="surveyView" style="margin-top:30px" onclick="reset()" value="重置" style="border:0px;" >
</td>
</tr> </form>
</div>

之前的有点问题,自己改过来的

04-04 08:49
查看更多