ScreamerHS Posted February 14, 2017 Share Posted February 14, 2017 I'm using a Bootstrap multiselect (https://github.com/davidstutz/bootstrap-multiselect ) which I want to validate on a form (defaultForm) with a formvalidator (The best jQuery validation plugin to validate form fields, support Bootstrap, Foundation, Pure, SemanticUI, UIKit frameworks - FormValidation) .This example works fine. It revalidate on selecting a option from the multiselect. 'tags[]': { validators: { callback: { message: 'Select one or more options</font>', callback: function(value, validator, $field) { var options = validator.getFieldElements('tags[]').val(); return (options != null && options.length >= 1 && options.length <= 10); } } } }, But I want this to validate when another dropdown menu has selected "Yes". (it has two options as a answer - Yes and No). I also get this thing to work with the following code. 'tags[]': { validators: { callback: { message: 'Select one or more options</font>', callback: function(value, validator, $field) { var x = document.getElementById("data_important"); var i = x.selectedIndex; return (x.options[i].text == 'No') ? true : (x.options[i].text == ''); } } } }, So both options works fine, but I can't get them combine together, that the it's going to validate only when another dropdown (data_important) is chosen"Yes" and that it revalidates when selecting a option on the multiselect with name "tags[]".Is there a fix to combine them together, that both elements works? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.