<html> <head> <title>javascript</title> <script language="javascript"> function validate(f) { var value = f.email.value; if(!/^\w+@\w+.\w+$/.test(value)) { alert("EMAIL 输入格式不正确!"); f.email.focus(); f.email.select(); return false; } return true; } </script> </head> <body> <form action="" method="post" name="myform" onSubmit="return validate(this)"> EMAIL:<input type="text" name="email"> <input type="submit" value="提交"> </form> </body> </html>
原文地址:http://blog.csdn.net/q389281541/article/details/44967283