手机号码登陆正则验证

2018-07-05  本文已影响0人  QRFF
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" id='user'>
    <button id='send'>发送</button>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <script>

        $('#send').click(function () {
            if(isPoneAvailable($('#user'))){
                console.log('正确')
            }else{
                console.log('错误')
            }
          
        })
        function isPoneAvailable($poneInput) {
            var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
            if (!myreg.test($poneInput.val())) {
                return false;
            } else {
                return true;
            }
        }
    </script>
   
</body>

</html>
上一篇 下一篇

猜你喜欢

热点阅读