首页  »   jQuery

jquery-validate 表单较比验

网友分享于:2013-12-24  浏览:0次
jquery-validate 表单较验

 

 (1)

<script type="text/javascript" src="/spring4mybatis3/easyui/jquery.min.js"></script>
<script type="text/javascript" src="/spring4mybatis3/easyui/jquery.validate.js"></script>

 

(2)

$().ready(function() {
    $("#form1").validate({
        rules:
        {
          userNo: {
           required: true,
           maxlength: 50
          },
          email:{
            required: true,
            email: true,
            equalTo: "#userNo"
          },
          phone:{
            required: true,
            minlength: 5
          },
          creDate:{
            required: true,
            minlength: 5
          }
        },
        messages:
        {
         userNo: {
           required: "请输入用户编号",
           maxlength: "长度不能大于50"
          },
          email:
          {
            required: "请输入Email地址",
            email: "请输入正确的email地址",
            equalTo: "email与用户编号不一致"
          },
          phone:
          {
            required: "请输入电话",
            //minlength: jQuery.format("密码不能小于{0}个字符")
            minlength: "密码不能小于5个字符"
          },
          creDate:
          {
            required: "请输入日期"
          }
        }
    });
  });

 

(3) 表单较验

 var isValid = $('#form1').valid();

 

 

相关解决方案

最新解决方案