Home > Article > Web Front-end > How to implement regular verification input of mobile phone number using jQuery
This article mainly introduces the jQuery implementation of mobile phone number regular verification input and automatic space filling functions, involving jQuery event response, string traversal and regular judgment and other related operating skills. Friends in need can refer to it
This article describes the example of jQuery's implementation of regular verification input and automatic filling of spaces for mobile phone numbers. Share it with everyone for your reference, the details are as follows:
Let’s take a look at the running effect first (you can delete it continuously when deleting):
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>
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Use the http module to send requests through nodejs (detailed tutorial)
How to implement a table using jQuery CSS
How to use Vue to implement the comment framework
The above is the detailed content of How to implement regular verification input of mobile phone number using jQuery. For more information, please follow other related articles on the PHP Chinese website!