easyUI之validatebox验证框

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>01_validatebox.html</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <link rel="stylesheet" href="../themes/default/easyui.css" type="text/css"></link>
    <link rel="stylesheet" href="../themes/icon.css" type="text/css"></link>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../js/easyui-lang-zh_CN.js"></script>
  </head>
  <body>
    
    
    <div style="margin:200px"></div>
    
    姓名:<input id="nameID"/><p/>
    
    <script type="text/javascript">
        $("#nameID").validatebox({
            required : true,
            validType : ['length[1,6]','zhongwen']
        });
    </script>
    <script type="text/javascript">
        //自定义规则:zhongwen
        $.extend($.fn.validatebox.defaults.rules, {    
            //zhongwen规则名
            zhongwen: {  
                //validator验证体  
                //value表示用户在文本框中输入的内容
                validator: function(value){   
                    //如果符合中文规则 
                    if(/^[\u3220-\uFA29]*$/.test(value)){
                        return true;    
                    }
                }, 
                //如果不符合中文规则,以下就是提示信息   
                message: '姓名必须为中文'   
            }    
        });  
    </script>
    
    
    
    
    
    
    
    
    
    邮箱:<input id="emailID"/><p/>

    <script type="text/javascript">
        $("#emailID").validatebox({
            required : true,
            validType : ['length[1,30]','email']
        });
    </script>
    
    
    
    
    密码:<input id="passwordID"/><p/>

    <script type="text/javascript">
        $("#passwordID").validatebox({
            required : true,
            validType : ['length[6,6]','english']
        });
    </script>
    <script type="text/javascript">
        $.extend($.fn.validatebox.defaults.rules, {    
            english: {  
                validator: function(value){   
                    if(/^[a-zA-Z]*$/.test(value)){
                        return true;    
                    }
                }, 
                message: '密码必须为英文'   
            }    
        });  
    </script>
    
  </body>
</html>

 

posted on 2018-12-04 10:20  LoaderMan  阅读(153)  评论(0编辑  收藏  举报

导航