bootstrapValidator adds or removes validation in js based on conditions

This is the start check code
function initValidate() {
	$('#detailform').bootstrapValidator({
					feedbackIcons : {
						valid : 'glyphicon glyphicon-ok',
						invalid : 'glyphicon glyphicon-remove',
						validating : 'glyphicon glyphicon-refresh'
					},
					fields : {
						txPassword : {
							validators : {
								notEmpty : {
									message : 'The transaction password cannot be empty'
								},
								notSameAndContinuity : {
									message : 'The password must be 6 different, non-consecutive numbers'
								}
							}
						}
					}
				});
       };
Sometimes we need to add or remove
addFile according to the conditions. ApprovalMemo is the name value of the input, and removeFile is used for removal.

$("#detailform").bootstrapValidator("addField", "approvalMemo", {  
			validators: {  
				notEmpty : {
					message : 'Approval comments cannot be empty'
				}
			}  
		});
$("#detailform").bootstrapValidator('removeField','approvalMemo');


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325886670&siteId=291194637