Home > Web Front-end > JS Tutorial > body text

Regular verification formula for mobile phone number

php中世界最好的语言
Release: 2018-03-15 11:35:09
Original
2410 people have browsed it

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>
Copy after login

# 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!