jQuery验证插件不提交表单

时间:2017-08-15 08:22:55

标签: javascript jquery forms validation

我正在使用https://jqueryvalidation.org

中的jQuery验证插件

实际表单本身并没有什么特别之处,它只是真正使用默认标记。

我遇到的问题是表单实际上并未在有效表单上提交,并且要求我再次单击“提交”按钮。我甚至尝试过将submitHandlerform.submit()一起使用

 <form action="/search/" method="post" id="postcode-search">
    <div class="input-wrap">
        <input type="input" id="postcode" name="postcode" class="director-search" placeholder="Enter your Postcode here" required><br>
        <div class="error-message"></div>
    </div>
    <button id="submit" type="submit" class="primary"><span class="inner"><i class="fa fa-search"></i> Search</span></button>
</form>

表单验证的代码在

之下
    $('form#postcode-search').validate({
        rules: {
            postcode: {
                required: true,
                remote: {
                    url: theme_location + 'inc/postcode-validation.php',
                    type: 'post',
                    data: {
                        postcode: function() {
                            return $('input#postcode').val();
                        }
                    }
                }
            }
        },
        messages: {
            postcode: {
                required: 'Please provide a full postcode.'
            }
        }
    });

0 个答案:

没有答案