title: Return false if no value is selected (other than heading) from select box
body: <p>I have a HTML form having select box. On selection of first drop down, next drop down should be auto filled using AJAX.</p>
  
  <p><a href="https://i.stack.imgur.com/d2Ezu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d2Ezu.png" alt="enter image description here"></a></p>
  
  <p>On <code>Download Records (id="getCsv")</code> button click event a CSV file is generated. Problem is, I want to make all the fields mandatory. Here is the jquery code</p>
  
  <pre><code>var teacher_name = $("#sel_teacher option:selected").text();
  var unittest_name = $("#sel_test1 option:selected").text();
  
  var class_name = $("#sel_class1 option:selected").text();
  var class_id = $('#sel_class1').val();
  
  var division_name = $("#sel_div1 option:selected").text();
  var division_id = $('#sel_div1').val();
  
  var subject_name = $("#sel_sub1 option:selected").text();
  
  if (teacher_name == "") {
      alert('Please Select Teacher Name.');
      return false;
  } else if(class_name == "") {
      alert('Please Select Class Name.');
      return false;
  } else if(division_name == "") {
      alert('Please Select Division Name.');
      return false;
  } else if(subject_name == "") {
      alert('Please Select Subject Name.');
      return false;
  } else if(unittest_name == "") {
      alert('Please Select Unit Test Name.');
      return false;
  } else {
      var myObject = new Object();
      myObject.class_name = class_name;
      myObject.class_id = class_id;
      myObject.division_name = division_name;
      myObject.division_id = division_id;
      myObject.subject_name = subject_name;
      myObject.test_name = unittest_name;
  
      var formData = JSON.stringify(myObject);
      $('#getCsv').attr('href','csv_generator.php?data=' + formData);
  }
  </code></pre>
  
  <p>The problem is that when I click <code>Download Records</code>, even though the first select box is empty directly alert box for second select box pops up. I tried to solve this problem using the below, but no luck.</p>
  
  <pre><code>if ($("#sel_teacher").attr("selectedIndex") == 0) {
     alert("You haven't selected anything!");
     return false;
  }
  </code></pre>
  
  <p>Can anybody please help me with this? Any help is appreciated.</p>