Javascript BootStrapValidator-使用excluded时不重置窗体
我正在使用BootstrapValidator,重置表单时遇到问题。当我将“:hidden”放在排除列表中时(我有隐藏的字段,当它们不显示时我需要跳过验证),表单将不会重置。我在下面提供了图像和更多文本:Javascript BootStrapValidator-使用excluded时不重置窗体,javascript,jquery,twitter-bootstrap-3,bootstrapvalidator,Javascript,Jquery,Twitter Bootstrap 3,Bootstrapvalidator,我正在使用BootstrapValidator,重置表单时遇到问题。当我将“:hidden”放在排除列表中时(我有隐藏的字段,当它们不显示时我需要跳过验证),表单将不会重置。我在下面提供了图像和更多文本: $('#frmLifecycleAddEdit').bootstrapValidator({ framework: 'bootstrap', excluded: [':disabled', ':hidden'], feedbackIcons: { va
$('#frmLifecycleAddEdit').bootstrapValidator({
framework: 'bootstrap',
excluded: [':disabled', ':hidden'],
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
txtStepName: {
validators: {
notEmpty: {
message: 'A valid step name is required.'
}
}
},
ddlCMCreateGroup: {
validators: {
notEmpty: {
message: 'CM creation group is required.'
}
}
},
ddlAssignGroup: {
validators: {
notEmpty: {
message: 'Assign group is required.'
}
}
},
ddlExpireGroup: {
validators: {
notEmpty: {
message: 'Expire group is required.'
}
}
},
txtDaysToExpire: {
validators: {
notEmpty: {
message: 'Expire days is required.'
}
}
},
txtStepNumber: {
validators: {
notEmpty: {
message: 'Step number is required.'
}
}
}
}
});
//View/Edit button click
$("#tblLifecycle tbody").on('click', 'button', function () {
var oTable = $('#tblLifecycle').DataTable();
var data = oTable.row($(this).parents("tr")).data();
$('#frmLifecycleAddEdit').bootstrapValidator('resetForm', true);
if ($('#ddlLifecycleName').val() == 'Accident') {
$('#mtAddEditStep').text('Edit Accident Step');
SetupEditAccident(data);
} else {
$('#mtAddEditStep').text('Edit Countermeasure Step');
SetupEditCountermeasure(data);
}
});
我正在尝试在按钮单击期间重置表单
$("#tblLifecycle tbody").on('click', 'button', function () {
var oTable = $('#tblLifecycle').DataTable();
var data = oTable.row($(this).parents("tr")).data();
$('#frmLifecycleAddEdit').bootstrapValidator('resetForm', true);
if ($('#ddlLifecycleName').val() == 'Accident') {
$('#mtAddEditStep').text('Edit Accident Step');
SetupEditAccident(data);
} else {
$('#mtAddEditStep').text('Edit Countermeasure Step');
SetupEditCountermeasure(data);
}
});
有人知道发生了什么吗?当我删除“:hidden”属性时,它会工作,但我需要它在其中,以便在所有字段都不存在时进行验证
提前谢谢 如果不显示控件,则无法重置,因此 您需要启用/禁用验证以解决此难题 首先将您的输入隐藏起来。 在验证设置中使被排除:':disabled',就像验证隐藏字段一样
if(条件)
{
$(“#mytextbox”).css(“显示”、“块”);
$('#Form').data('bootstrapValidator').enableFieldValidators('mytextbox',true);
}否则
{
$(“#mytextbox”).css(“显示”、“无”);
$('#Form').data('bootstrapValidator').enableFieldValidators('mytextbox',false);
}