• support@answerspoint.com

Using jquery validation plugin to validate multiselect box created using bootstrap multiselect plugin?


I am using jquery validation plugin and lately I had to add multi-select dropdown in my form. I used davidstutz bootstrap multiselect plugin. However, could not validate the multiselect box below is my html code , I submit with selecting a value from multiselect box without giving other form inputs even then form gets submitted,

<select name="franchisee_course" class="multiselect" multiple="multiple"  id="franchisee_course" size="1" placeholder="Courses">

                  foreach($courses as $course) {
                  echo "<option value=".$course['course_id']." >".$course['course_description']."</option>";


and my calling multi-select,


          noneSelectedText: 'Select Courses',
          includeSelectAllOption: true,
          enableFiltering: true,
          filterPlaceholder: 'Search course'


and these are my validation codes for multiselect,

$.validator.addMethod("needsSelection", function(value, element) {
               return $(element).multiselect("getChecked").length > 0;

          $.validator.messages.needsSelection = 'Select Atleast One Course';

          franchisee_course: {

                needsSelection: true,

         ignore: ':hidden:not("#franchisee_course")', // I don't know what this line does




The problem is that the "getChecked" argument doesn't do anything anymore. Here is an updated, working version of the validation method

$.validator.addMethod("needsSelection", function (value, element) {
    var count = $(element).find('option:selected').length;
    return count > 0;


  • answered 7 years ago
  • Gul Hafiz

Your Answer

    Facebook Share        
  • asked 7 years ago
  • viewed 4731 times
  • active 7 years ago

Best Rated Questions