1234567891011121314151617181920212223242526272829303132 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <script>
- /*
- 电子邮件
- hello@abc.com.cn(hello.li@abc.com.cn)
- 规则:
- 任意字母数字下划线 .任意字母数字下划线 @ 任意字母数字 . 任意字母(2-5位) . 任意字母(2-5位)
-
- \w{3,} (\. \w+)* @ [A-z0-9]+ (\. [A-z]{2,5}){1,2}
- */
- var emailReg = /^\w{3,}(\.\w+)*@[A-z0-9]+(\.[A-z]{2,5}){1,2}$/;
- // var email = "abc@bcd.com.123";//false
- // var email = "abc@bcd.com";//true
- // var email = "123abc.hello@bcd.com";//true
- var email = "@abc.hello@bcd.com";//false
- console.log(emailReg.test(email));
- </script>
- </head>
- <body>
-
- </body>
- </html>
|