susanahernandezd
1/5/2017 - 9:51 AM

jqBootstrapValidation_change_validations.js

var validateMotiveOthers = function(){

		//On click cancelation reason if it is OTHERS one, add comments as required
		$('#cancelation-reason li').click(function(){

			var $inputs = $('#comments');

			if($(this).hasClass('js-others')){
				//add required
				$inputs.attr('required','required');

				$inputs.jqBootstrapValidation(); // set up; ideally only called on each field once
				// triggers the field(s) to show the error-state if something is wrong
				$inputs.trigger("change.validation", {submitting: true});

			}else{
				//remove required
				$inputs.removeAttr('required','required');
				$inputs.removeData('validationRequiredMessage');
				$inputs.jqBootstrapValidation(); // set up; ideally only called on each field once
				// triggers the field(s) to show the error-state if something is wrong
				$inputs.trigger("change.validation", {submitting: true});
			}
		});
		
	};