Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 提交处理程序不工作_Javascript_Jquery_Html_Validation - Fatal编程技术网

Javascript 提交处理程序不工作

Javascript 提交处理程序不工作,javascript,jquery,html,validation,Javascript,Jquery,Html,Validation,我尝试使用Jquery,我需要在提交时使用不起作用的提交处理程序传递表单的值。我是Jquery新手,不知道出了什么问题。下面是我的Javascript代码 $('document').ready(function() { jQuery.validator.addMethod('minStrict', function(value, el, param) { if (value == '') { return true; } return value &

我尝试使用Jquery,我需要在提交时使用不起作用的提交处理程序传递表单的值。我是Jquery新手,不知道出了什么问题。下面是我的Javascript代码

$('document').ready(function() {


  jQuery.validator.addMethod('minStrict', function(value, el, param) {
    if (value == '') {
      return true;
    }
    return value >= param;
  });

  $.validator.addMethod('reqStrict', function(value, el, param) {
    alert(value);
    alert(el.id);
    alert(value == '');
    return value.length >= param;
  });


  $('#form1').validate({
    rules: {
      keyword1: {
        reqStrict: 1
      },

      MinPrice: {
        minStrict: 0,
        number: true
      },
      MaxPrice: {
        minStrict: function(element) {
          return $("#MinPrice").val() > 0 ? $("#MinPrice").val() : 0;
        },
        number: true
      },
      MaxHandlingTime: {
        minStrict: 1,
        digit: true,
      }

    },
    messages: {
      keyword1: "Please enter a keyword",
      MinPrice: {
        minStrict: "Minimum price cannot be below 0",
        number: "Price should be a valid number "
      },
      MaxPrice: {
        minStrict: "Maximum price cannot be less than minimum price or below 0",
        number: "Price should be a valid number "
      },
      MaxHandlingTime: {
        digit: "Max Handling time should be a valid digit",
        minStrict: "Max Handling time should be greater than or equal to 1"
      }

    },
    highlight: function(element) {
      $(element).closest('.form-group').addClass('has-error');
    },
    unhighlight: function(element) {
      $(element).closest('.form-group').removeClass('has-error');
    },
    errorElement: 'span',
    errorClass: 'help-block',
    errorPlacement: function(error, element) {
      if (element.parent('.input-group').length) {
        error.insertAfter(element.parent());
      } else {
        error.insertAfter(element);
      }
    },
    submitHandler: function() {
      alert("Hey babe");
    }
  });
});

您能告诉我哪里出了问题。

控制台有错误吗?你在使用什么样的验证插件?请看,如果共识是否定的,他们就不应该这样做!如果你打算使用来自互联网的代码,最好从简单的开始。