jquery.validate.min.js同一页面验证多个表单
taotaoit jQuery 2021-04-22 427 0
关于本站

本人承接php网站维护,病毒查杀,网站编辑,网站改版,html制作

有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339

2032807 1790 18
最新评论
如果在每个单词下面标上注释和用意就更好了
评 js按大写字母拆分字符串
报错 in promise) MiniProgramError {"errMsg":"removeTabBarBadge:fail not TabBar page"} Object
评 人人商城小程序昵称变成了“微信用户”头像也不显示?getUserInfo换成getUserProfile
按照这个修改后报错: ReferenceError: n is not defined at success (index.js? [sm]:3) at Function.forEach.u.<computed> (VM10210 WAService.js:2) at :55237/appservice/<api login success callback function> at Object.success (VM10210 WAService.js:2) at r (VM10210 WAService.js:2) at VM10210 WAService.js:2 at w (VM10210 WAService.js:2) at VM10210 WAService.js:2 at VM15 asdebug.js:1 at I (VM15 asdebug.js:1)(env: Windows,mp,1.05.2105170; lib: 2.17.0)
评 人人商城小程序昵称变成了“微信用户”头像也不显示?getUserInfo换成getUserProfile
asfdsafasdf
评 ;!function(){}();
:kaixin:
评 thinkphp 3.2.3 Runtime\Logs日志文件太多怎么关闭日志功能
文章标签更多
ThinkPHP (199)
Mysql (41)
DedeCms (33)
jQuery (45)
证件照 (1)
setInc (4)
setDec (4)
onclick (5)
打开边栏(ESC) 关闭边栏(ESC)

代码

$(document).ready(function () {
  // 表单提交验证
  // $.validator.setDefaults({
    
  // });
  // 验证身份表单
  $('#quickForm').validate({
    submitHandler:function(form){
      var loading = ZHT.msg('正在操作,请稍后...', {icon:16,time:60000});
      var params = ZHT.getParams('.ipt');
      // console.log(params);
      $.post(ZHT.U('shop/user/forgetPayPassCheck'),params,function(data,textStatus){
        layer.close(loading);
        json = ZHT.toJson(data);
        if(json.status=='1'){
          ZHT.msg(json.msg,{icon:1},function(){
            location.href = ZHT.U('shop/user/forgetPayPass2');
          });
        }else{
          ZHT.msg(json.msg,{icon:0});
        }
      });
    },
    rules: {
      verifyCode: {
        required: true,
      },
      emailCode: {
        required: true,
      },
    },
    messages: {
      verifyCode: {
        required: "请输入验证码",
      },
      emailCode: {
        required: "请输入校验码",
      },
    },
    errorElement: 'span',
    errorPlacement: function (error, element) {
      error.addClass('invalid-feedback');
      element.closest('.form-group').append(error);
    },
    highlight: function (element, errorClass, validClass) {
      $(element).addClass('is-invalid');
    },
    unhighlight: function (element, errorClass, validClass) {
      $(element).removeClass('is-invalid');
    }
  });
  // 设置支付密码表单
  $('#quickForm2').validate({
    submitHandler:function(form){
      var loading = ZHT.msg('正在操作,请稍后...', {icon:16,time:60000});
      var params = ZHT.getParams('.ipt');
      // console.log(params);
      $.post(ZHT.U('shop/user/forgetPayPass2Check'),params,function(data,textStatus){
        layer.close(loading);
        json = ZHT.toJson(data);
        if(json.status=='1'){
          ZHT.msg(json.msg,{icon:1},function(){
            location.href = ZHT.U('shop/user/forgetPayPass3');
          });
        }else{
          ZHT.msg(json.msg,{icon:0});
        }
      });
    },
    rules: {
      payPass: {
        required: true,
        minlength: 5,
      },
      payPass2: {
        required: true,
        minlength: 5,
        equalTo: "#payPass",
      },
    },
    messages: {
      payPass: {
        required: "请输入支付密码",
        minlength: "密码长度不能小于5",
      },
      payPass2: {
        required: "请输入确认支付密码",
        minlength: "密码长度不能小于5",
        equalTo: "两次密码输入不一致",
      },
    },
    errorElement: 'span',
    errorPlacement: function (error, element) {
      error.addClass('invalid-feedback');
      element.closest('.form-group').append(error);
    },
    highlight: function (element, errorClass, validClass) {
      $(element).addClass('is-invalid');
    },
    unhighlight: function (element, errorClass, validClass) {
      $(element).removeClass('is-invalid');
    }
  });
});
如果验证一个表单的话,可以是

$(document).ready(function () {
  // 表单提交验证
  $.validator.setDefaults({
    submitHandler:function(form){
      var loading = ZHT.msg('正在操作,请稍后...', {icon:16,time:60000});
      var params = ZHT.getParams('.ipt');
      // console.log(params);
      $.post(ZHT.U('shop/user/editPayPass'),params,function(data,textStatus){
        layer.close(loading);
        json = ZHT.toJson(data);
        if(json.status=='1'){
          ZHT.msg(json.msg,{icon:1},function(){
            location.href = ZHT.U('shop/user/security');
          });
        }else{
          ZHT.msg(json.msg,{icon:0});
        }
      });
    }
  });
  $('#quickForm').validate({
    rules: {        
      payPassOld: {
        required: true,
      },
      payPass: {
        required: true,
        minlength: 5,
      },
      payPass2: {
        required: true,
        minlength: 5,
        equalTo: "#payPass",
      },
    },
    messages: {
      payPassOld: {
        required: "请输入原支付密码",
      },
      payPass: {
        required: "请输入支付密码",
        minlength: "密码长度不能小于5",
      },
      payPass2: {
        required: "请输入确认支付密码",
        minlength: "密码长度不能小于5",
        equalTo: "两次密码输入不一致",
      },
    },
    errorElement: 'span',
    errorPlacement: function (error, element) {
      error.addClass('invalid-feedback');
      element.closest('.form-group').append(error);
    },
    highlight: function (element, errorClass, validClass) {
      $(element).addClass('is-invalid');
    },
    unhighlight: function (element, errorClass, validClass) {
      $(element).removeClass('is-invalid');
    }
  });
});

版权声明:本站原创文章,允许自由转载。

相关推荐
jquery出现Uncaught TypeError: $(...).prop is not a function问题
jQuery | 2019-08-23 3600
做全选功能的时候用到 var xz = $(this).prop("checked"); 提示: Uncaught TypeError: $(...).prop is not a function 应该是jquery版本过低造成的,更换高版本成功解决问题, jquery下载地址 http://www...
js,jquery获取不到动态创建的元素id的解决办法
jQuery | 2017-09-15 2586
js获取不到动态创建的元素id的解决办法: 如之前动态创建了 id为  "a" 的 input标签。 $("**").click(function(){     // 这样是获取不到的 $("#a").val() });  $("**").live('click',function(){ &...
评论:0条
评论加载中...
发表评论