RegExp 对象
    exec 检查字符中是正则表达中的区域
    text  检查内容
  String 对象的方法
    match
    search
    replace
    splict
正则表达式符号
    /.../ 开始与结束     ^开始    $结束
     /s 任何空白字符     /S任何非空白 
    /d  匹配数字    /D除去任何数字的字符    
    /w  变量命名规则    {n}匹配前一项N次   
     {n,}匹配前一项N次 或者多次    {n,m} 匹配至少n次 但不能超过m次
示例:var reg = /^1([3-5]|[7-8])\d{9}$/

HTML5  实战
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script src="js/jquery-3.1.1.js"></script>
        <script type="text/javascript">
            $(function(){
                $('#Go_submit').click(function(){
                    var obj_ =document.getElementById('form_tel');
                    if(obj_.validity.valueMissing==true){
                        obj_.setCustomValidity('手机号不能为空哦')
                    }else if(obj_.validity.patternMismatch == true){
                        obj_.setCustomValidity('请填写正确的手机号')
                    }
                    //如果判断邮箱那么可以
                    xx.validity.typeMismatch  //可以判断邮箱
                })
            });
        </script>
    </head>
    <body>
        <form action="#" method="get">
            <input type="tel" >ml>

     

相关文章:

  • 2021-07-29
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
猜你喜欢
  • 2021-07-01
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-08-02
相关资源
相似解决方案