做个参考吧
<script language="javascript">
function ckemail()
{
var reg=/^\s*([A-Za-z0-9_-]+(\.\w+)*@([\w-]+\.)+\w{2,3})\s*$/;
if(reg.test(form1.email.value))
{
return true;
}
else
{
return false;
}
}
function check()
{
if(!ckemail())
{
alert("邮箱格式错误!");
form1.email.focus();
return false;
}
if(form1.us.value=="")
{
alert("姓名不能为空!");
form1.us.focus();
return false;
}
return true;
}
</script>
<form name=form1>
邮件:<input type=text name=email><br>
姓名:<input type=text name=us>
<input type=submit name=s1 value="提交" onclick="return check();">
</form>