<script language="JavaScript">
function validate(e){
var value=e.email.value;
if(!/^\w+@\w+.\w+$/.test(value)){
alert("email格式错误!");
e.email.focus();
e.email.select();
return false;
}
alert("email格式正确!");
return true;
}
</script>
</head>
<body >
<form action="" method="post" name="e" onSubmit="return validate(this)">
Email:<input type="text" name="email"/>
<input type="submit" value="提交">
</form>
</body>
function validate(e){
var value=e.email.value;
if(!/^\w+@\w+.\w+$/.test(value)){
alert("email格式错误!");
e.email.focus();
e.email.select();
return false;
}
alert("email格式正确!");
return true;
}
</script>
</head>
<body >
<form action="" method="post" name="e" onSubmit="return validate(this)">
Email:<input type="text" name="email"/>
<input type="submit" value="提交">
</form>
</body>