Home  >  Article  >  Web Front-end  >  Regular verification formula for mobile phone number

Regular verification formula for mobile phone number

php中世界最好的语言
php中世界最好的语言Original
2018-03-15 11:35:092408browse

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!

Statement:
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