2021年最新js手機號正則驗證 最全全部號段

手機號驗證正則

/^1[3-9]\d{9}$/

js的例子 isphone.html

<html>
<body>
<input id="Tel" type="text" value="18988889999">
<button onclick="myFunction()">驗證號碼</button>
<script>
function myFunction(){
  isPhone(document.getElementById("Tel").value);
}
function isPhone(phone) {
            var myreg=/^1[3-9]\d{9}$/;
            if (!myreg.test(phone)) {
                alert('no');
            } else {
                alert('yes');
            }
        }
</script>
</body>
</html>

 用自己私人的服務器來測試吧,99買阿里雲

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章