<script language='javascript'>
function chk(){
var title=document.form1.title.value;
var author=document.form1.author.value;
var email=document.form1.email.value;
if(title==""){
alert("输入的主题不能为空");
document.form1.title.focus();
return false;
}
if(author==""){
alert("请输入您的名字");
document.form1.author.foucs();
return false;
}
if(email==""){
alert("请填写邮箱地址!");
document.form1.email.focus();
return false;
}
//开始验证
// var email = document.form1.email.value;
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(/.[a-zA-Z0-9_-])+/;
chkFlag = pattern.test(email);
if(chkFlag){
document.form1.action="addManagerMsg.do";
document.form1.submit();
return true;
}
else
{
alert("邮箱地址的格式不正确!");
document.form1.email.focus();
return false;
}
}
<form name = "f1" method="post" action="aa.do">
<input ……>
<input type="button" name="Submit" value="提交留言" οnclick="chk()" />
</foem>