Can jqBootstrapValidation.js validate selects (dropdown list)?

1.7k views Asked by At

I'm using the plugin jqBootstrapValidation.js to validate my contact form. I need to have a dropdown list where the visitor needs to select an option from the dropdown list. So if the visitor left the dropdown list in its default state, there needs to be a warning message asking the visitor to select an option.

enter image description here

My question is, can I use the jqBootstrapValidation.js to validate selects? Because I don't see selects under the validators in the documentation: https://reactiveraven.github.io/jqBootstrapValidation/

Or do I need to use the plugin jquery.validate.js? As in this asked question here (the last example with the JSFIDDLE): Bootstrap validator- dropdown list

If I do need to use jquery.validate.js, can I still keep all the codes relating to jqBootstrapValidation.js?

I'm a newbie at contact forms, js, php so I would like to keep everything as simple as possible. Thank you!

1

There are 1 answers

1
Daltom On

Yes, You can use the jqBootstrapValidation.js to validate selects, this is a way: You need put value="" required and $("input,select,textarea").jqBootstrapValidation({...

$("input,select,textarea").jqBootstrapValidation({...

<select id="mydropdown" name="mydropdown" 
data-validation-required-message="This Is Required" required >
  <option value="">
  Choose
  </option>
  <option value="One">
  One
  </option>
  <option value="Two">
  Two
  </option>
  <option value="Three">
  Three
  </option>
</select>
<p class="help-block"></p>