简单正则匹配QQ邮箱

自古美人都是妖i 提交于 2019-11-28 03:49:45

 

 

<!DOCTYPE html><html>   <head>      <meta charset="UTF-8">      <script src="../jquery-3.1.0.js" ></script>      <title></title>      <style type="text/css">          #txt{             border: 2px solid #90EE90;             font-size: 20px;          }         #txt2{            margin-top: 100px;            width: 200px;            height: 50px;            border: 2px solid blue;            text-align: center;            font-size: 25px;         }         #btn{            width: 200px;            height: 50px;            font-size: 40px;            font-weight: bold;            background-image: linear-gradient(pink,lightblue,lightgreen);         }      </style>   </head>   <body>      <textarea  rows="5" cols="30" id="txt"></textarea><br>      <input type="button" name="btn" id="btn" value="验证" /><br>       <input type="text" name="" id="txt2" value="" />   </body></html><script type="text/javascript">      $(function(){             var txt =document.getElementById('txt');       var txt2 = document.querySelector('#txt2')         var btn =document.getElementById('btn');            btn.onclick = function(){                 var reg1 = /^\w{5,}@[a-z0-9]{2,3}\.[a-z]+$|\,$/;        if(reg1.test(txt.value))        {                       txt2.value = '验证成功!'            var a1 = txt2.value            console.log(a1)            $('#txt2').css('color','blue')        }        else        {            txt2.value = '验证失败!'            $('#txt2').css('color','red')                    }    }         })   </script>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!