如何从 Ideal Forms 中删除验证规则 jQuery
How to remove validation Rule from Ideal Forms jQuery
正在尝试从 Ideal Forms 中删除验证规则,但无法摆脱它!。
当值小于 3 时,我正在添加规则来验证 4 个额外字段,但是当我输入的值大于 3 时,我希望删除此验证。我一直在尝试在 else 语句中添加但不起作用。请帮忙
$('#previous_year').keyup("input", function() {
var dInput = this.value;
if(parseInt(dInput) < 3){
$('form.idealforms').idealforms('addRules', {
'postcode4': (parseInt(dInput) < 3) ? 'required' : '',
'memo3': (parseInt(dInput) < 3) ? 'required' : '',
'previous_year2': (parseInt(dInput) < 3) ? 'required' : '',
'previous_month2': (parseInt(dInput) < 3) ? 'required' : ''
});
$('form.idealforms').idealforms('goToStep', 3);
} else {
//remove rule here!
}
});
查看了文档,我得到了以下更新,但这仍然是错误的,就好像你已经下拉并且你 select 一个选项你正在禁用元素,如果你 select 其他您正在启用它的选项,它是一个直接循环
.idealforms('toggleFields', names)
Show or hide fields. When the fields are hidden they will be excluded from the validation.
names: A space separated string of name attributes.
Example:
$('form').idealforms('toggleFields', 'username password hobbies[]');
$('#employment_details').change(function() {
if (this.value == 'Retired') {
$('form.idealforms').idealforms('toggleFields', 'company_name getemployed');
$('form.idealforms').idealforms('goToStep', 5);
}
if (this.value == 'Employed') {
$('form.idealforms').idealforms('toggleFields', 'monthly_pension_amount pension_type getretired');
$('form.idealforms').idealforms('goToStep', 5);
}
$('#employment_details').attr('disabled', 'disabled');
});
正在尝试从 Ideal Forms 中删除验证规则,但无法摆脱它!。 当值小于 3 时,我正在添加规则来验证 4 个额外字段,但是当我输入的值大于 3 时,我希望删除此验证。我一直在尝试在 else 语句中添加但不起作用。请帮忙
$('#previous_year').keyup("input", function() {
var dInput = this.value;
if(parseInt(dInput) < 3){
$('form.idealforms').idealforms('addRules', {
'postcode4': (parseInt(dInput) < 3) ? 'required' : '',
'memo3': (parseInt(dInput) < 3) ? 'required' : '',
'previous_year2': (parseInt(dInput) < 3) ? 'required' : '',
'previous_month2': (parseInt(dInput) < 3) ? 'required' : ''
});
$('form.idealforms').idealforms('goToStep', 3);
} else {
//remove rule here!
}
});
查看了文档,我得到了以下更新,但这仍然是错误的,就好像你已经下拉并且你 select 一个选项你正在禁用元素,如果你 select 其他您正在启用它的选项,它是一个直接循环
.idealforms('toggleFields', names)
Show or hide fields. When the fields are hidden they will be excluded from the validation.
names: A space separated string of name attributes.
Example:
$('form').idealforms('toggleFields', 'username password hobbies[]');
$('#employment_details').change(function() {
if (this.value == 'Retired') {
$('form.idealforms').idealforms('toggleFields', 'company_name getemployed');
$('form.idealforms').idealforms('goToStep', 5);
}
if (this.value == 'Employed') {
$('form.idealforms').idealforms('toggleFields', 'monthly_pension_amount pension_type getretired');
$('form.idealforms').idealforms('goToStep', 5);
}
$('#employment_details').attr('disabled', 'disabled');
});