jQuery验证 - 不形成提交

时间:2016-11-16 11:48:35

标签: javascript jquery forms validation jquery-plugins

我正在使用jQuery验证插件。它验证成功,但在正确提交表单后没有提交。

以下是代码:

jQuery.validator.setDefaults({
          debug: true,
          success: "valid"
        });
        $("#myform").validate({
          rules: {
            ip: {
                required: true,
                maxlength: 15,
                minlength: 11
            },
            assert_code: {
                required: true,
                maxlength: 17,
                minlength: 17
            }            
          }
        });

 form example
      <form id = "myform" method = "post" >
      <input type = "text" name = "ip" id = "ip"/>
      <input type = "text" name = "assert_cpde" id = "assert_code"/>
      <input type = "submit" name = "submit" />
      </form>

2 个答案:

答案 0 :(得分:0)

您有assert_code名称(您撰写assert_cpde

的拼写错误

正确版本:

<form id = "myform" method = "post" >
    <input type = "text" name = "ip" id = "ip"/>
    <input type = "text" name = "assert_code" id = "assert_code"/>
    <input type = "submit" name = "submit" />
</form>

答案 1 :(得分:0)

所有我需要编写像这样的代码。并完成它!

$(function() {
    $("#myform").validate({
      rules: {
        ip: {
            required: true,
            maxlength: 15,
            minlength: 11
        },
        assert_code: {
            required: true,
            maxlength: 17,
            minlength: 17
        }            
      }
    });
});