jquery.validate中是否有一个函数可以像表单的resetForm一样重置单个字段? [英] Is there a function in jquery.validate that will reset a single field like resetForm does for a form?

查看:328
本文介绍了jquery.validate中是否有一个函数可以像表单的resetForm一样重置单个字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调用一个jquery函数,以从单个字段中手动删除错误并重置错误标记.是否有一个与resetForm函数类似的函数?

I want to call a jquery function to manually remove errors from a single field and reset the error markup. Is there a function that does this that would be similar to the resetForm function?

推荐答案

重置整个表单

this resets the entire form

var validator = $("#myform").validate();
validator.resetForm();

仅重置元素

this will reset only the name element

$("#skip").click(function() {
   var rules = $("#name").removeAttrs("min max"); // remove min and max
   $("#form").submit(); // submit, as there are no attributes, it will not have an error
   $("#name").attr(rules); // add it again so you can validate it
});

这篇关于jquery.validate中是否有一个函数可以像表单的resetForm一样重置单个字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆