title: Form validation (radio & combobox) in javascript
body: <p>I am trying to validate radiobuttons and optionbox in javascript. Here is the code but it is not working...
  Javascript Code for OprionBox and Radio:</p>
  
  <pre><code>function checkCountry()
          {
          if(document.form.country.selectedIndex=="")
          {
          alert("Please select country from the list");
          return false;  
          }
          return true
          }
  function checkGender()
          {
          if(!document.getElementsByName("sex")[0].checked &amp;&amp; !document.getElementsByName("sex")[1].checked)
          {
          alert("Select Male/Female");
          return false;
          }
          return true;
          }
  function validate()
        {
              checkCountry();
              checkGender();
        }
  </code></pre>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;form name="form" method="post" onSubmit="return validate()"&gt;                
      &lt;select name="country"&gt;
      &lt;option value="select"&gt;(Please select a country)&lt;/option&gt;
      &lt;option value="pk"&gt;Pakistan&lt;/option&gt;
      &lt;option value="chn"&gt;China&lt;/option&gt;
      &lt;option value="uk"&gt;United Kingdom&lt;/option&gt;
      &lt;option value="usa"&gt;United States of America&lt;/option&gt;
      &lt;option value="ir"&gt;Iran&lt;/option&gt;
      &lt;option value="ma"&gt;Malaysia&lt;/option&gt;
      &lt;/select&gt;&lt;br&gt;
      &lt;input type="radio" name="sex" value="male"&gt;Male&lt;br&gt;
      &lt;input type="radio" name="sex" value="female"&gt;Female&lt;br&gt;&lt;/form&gt;
  </code></pre>
  
  <p>Please help...</p>