[英]How to remove validation Rule from Ideal Forms jQuery
試圖從“理想形式”中刪除驗證規則,並且無法擺脫它! 當值小於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!
}
});
查看了文檔,我得到了以下更新,但是這仍然表現不佳,就好像您已經下拉菜單並選擇了一個禁用元素的選項,如果選擇了另一個選項則啟用了它,則它是一個直接循環
.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');
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.