更新时间:2023-12-03 15:51:40
假设将验证应用于表单后,没有实际的方法可以关闭"验证,您可以使用validate方法,但是将其设置为忽略所有内容形式?
Assuming there's no practical way to "turn off" validation once it's been applied to a form, can you use the validate method, but set it ignore everything in the form?
$(document).ready(function()
{
$('.cbyes').click(function()
{
$('.hiddenDiv').show('slow');
$("#regForm").validate();
});
$('.cbno').click(function() {
$('.hiddenDiv').hide('slow');
$('#regForm')[0].reset();
$('#regForm').validate({
ignore: "#regForm *"
});
});
});
此示例使用了一个愚蠢的通用选择器,应将其替换为更适合您特定形式的内容.
This example uses a dumb universal selector that should be replaced with something more appropriate for your particular form.