手機號驗證正則表達式+Demo(親測完畢)


以下為本人親測過的驗證手機號格式的demo,需要的小伙伴拿走不謝~
1
<!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title></title> 6 7 <!--這里換成你自己的jquery地址--> 8 <script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script> 9 10 <style type="text/css"> 11 #phone_msg{ 12 color: red; 13 font-size: 12px; 14 } 15 </style> 16 </head> 17 <body> 18   <input type="text" id="phonenumber"/> 19   <button>點擊跳轉</button> 20   <p id="phone_msg"></p> 21   <script type="text/javascript"> 22   $("button").click(function(){ 23   // 獲取輸入框 24   var phoneInput = $("#phonenumber"); 25   // 獲取輸入框內容 26   var phonenumber = $("#phonenumber").val(); 27 28   // 驗證手機號碼格式 29   function isPoneAvailable(phoneInput){ 30   var myreg=/^[1][3,4,5,7,8][0-9]{9}$/; 31   if (!myreg.test(phonenumber)) { 32   $("#phone_msg").html("請輸入正確的手機號格式"); 33   return false; 34   } else { 35   $("#phone_msg").html("驗證成功,此條可不顯示"); 36   return true; 37   } 38   } 39   isPoneAvailable(); 40   }) 41   </script> 42 </body> 43 </html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM