js 驗證手機號碼

function validatemobile(phone)
   {
       if(phone.length==0)
       {
          alert('請輸入手機號碼!');
          document.form1.phone.focus();
          return false;
       } 
       if(phone.length!=11)
       {
           alert('請輸入有效的手機號碼!');
           document.form1.phone.focus();
           return false;
       }
            
       var myreg = /^13[0-9]{9}$|14[0-9]{9}$|15[0-9]{9}$|18[0-9]{9}$/;
       if(!myreg.test(phone))
       {
           alert('請輸入有效的手機號碼!');
           document.form1.phone.focus();
           return false;
       }
   }


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