title: Using JavaScript to validate a multiple select box is not empty
body: <p>I’m trying to use JavaScript to validate a multiple select box is not empty. Below is the code I use on all the other input boxes (without [] in the field name).</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function validateForm()
  {
  var x=document.forms["escalations"]["SupportGroup[]"].value;
   if (x==null || x=="" || x=="---&lt; Select Delivery Team &gt;---")
     {
     alert("Please select a Support Group.");
     return false;
     }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And it works fine for single input but when I add the “[]” for multiple, it then alerts when an option is chosen or not. Any ideas? Thanks.</p>
  
  <p>The html code is </p>
  
  <pre><code> &lt;form name="escalations" onsubmit="return validateForm()" action="submitescalation.php?SM=SN" method="post" enctype="multipart/form-data"&gt;
   &lt;select id="s0" multiple="multiple" name="SupportGroup[]" onchange="GetCompany();GetTitle();GetContact();" style="height: 25px"&gt;
   &lt;option&gt;Company1&lt;/option&gt;&lt;option&gt;Company2&lt;/option&gt;&lt;option&gt; Company3&lt;/option&gt;&lt;/select&gt;
   &lt;/form&gt;
  </code></pre>