JavaScript正则表达式验证邮箱地址 1999年11月30日JavaScriptemail、js、正则、正则表达式、验证emailsheng00 <html> <head> <script type="text/javascript" language="javascript"> function check() { var email = document.getElementById("in").value; if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email)){ document.getElementById("div1").innerHTML = "valid"; }else{ document.getElementById("div1").innerHTML = "invalid"; } } </script> </head> <body> <div> Email:<input id="in" type="text" onkeyup="check();" /> <div id="div1"></div> </div> </body> </html> 提示:你可以先修改部分代码再运行。 Email: 相关