Home > Article > Web Front-end > Regular verification formula for mobile phone number
This time I will bring you the regular verification formula for mobile phone numbers. What are the precautions when using the regular verification formula for mobile phone numbers? The following is a practical case, let’s take a look.
Let’s take a look at the running effect first (you can delete it continuously when deletes ):
Specific code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <input type="text" id="inp"> <script src="jquery-1.12.3.min.js"></script> <script> $(function(){ $("#inp").keyup(function(){ /* 手机号验证时: var pattern = /^1[3|4|5|7|8]\d{1}\s\d{4}\s\d{4}$/; pattern.test(str); */ _self = $(this); if(_self.val().length == 3 || _self.val().length == 8){ var str = _self.val()+" "; _self.val(str); } }); }); </script> </body> </html>
# I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
What should be done if the jquery trigger function cannot trigger a tag
How to use jquer to implement table rows and columns Interchange
jquery form validation submission
The above is the detailed content of Regular verification formula for mobile phone number. For more information, please follow other related articles on the PHP Chinese website!