问题描述
我在全局JS文件中有一个通用的jQuery验证调用:
I have a generic jQuery validation call in a global JS file:
$('form').each(function() {
$(this).validate();
});
这样,网站上的任何表格都可以通过简单地提供元数据来启用验证.但是,现在我要重置表单,因为我正在执行AJAX提交.在官方网站上,它说要使用创建的对象来重置表单:
This way, any forms on the website can enable validation by simply providing metadata. However, now I want to reset the form because I'm doing AJAX submits. On the official website, it says to reset forms by using the created object:
var validator = $('#someForm').validate();
问题是,使用我的通用验证器设置,我没有对创建对象的引用.我有没有办法在我的情况下取回它?
Problem is, with my generic validator setup, I don't have a reference to the created object. Is there a way I can still retrieve it in my case?
推荐答案
我不确定我重置表格会理解您的意思.以防万一...
I'm not sure I understand what you mean by reset the forms. Just in case...
您可以像这样删除验证.
You can remove validation like this..
$("form").removeData("validator");
$("form").removeData("unobtrusiveValidation");
这篇关于使用jQuery验证,有没有一种方法可以在不引用创建的对象的情况下重置表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!