title: Validation ASP Classic DDL
body: <p>Unfortinatly I need to use ASP classic...
  I have a drop down list that I load from database, but i can validate it..I need to do validation with JavaScript</p>
  
  <pre><code>&lt;select name= "ddlCategories"&gt;
                      &lt;option value="-1"&gt;  choose
                          &lt;/option&gt;
                      &lt;%set con = Server.CreateObject("ADODB.Connection")
                      con.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &amp; Server.MapPath("WebData/DB.mdb") &amp; ";"
                      set rs = con.Execute("Select * FROM Categories where mode=true")
                      while not rs.eof%&gt;
                      &lt;option value="&lt;%=rs("CatID")%&gt;"&gt;&lt;%=rs("CategoryName")%&gt;&lt;/option&gt;
                          &lt;%rs.movenext
                          wend
                          rs.close
                      set rs= nothing
                      Con.close%&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>-1 it is the default value, and in this value the validation need to work..</p>
  
  <p>Hope you understand me, Thanks</p>
  
  <p>This is the validation for the TextBox</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function ValidationAddCategory()
  {
  var cName = document.form.tbCategory.value;
  if (cName== "")
      {
          alert("Please insert category name")
          return(false)
      }
      return ture 
  }
  
  function ValidationDelCategory() {
            var oForm = document.getElementById('admin');
            var oTemp, strErrors='';
  
            //check 1
            oTemp = document.getElementById('ddlCategories');
            if (oTemp.value=='-1') {
              strErrors+='- Please select a category\n';
            }
  
            //put more checks here for any other validation, add to strErrors
  
            if (strErrors) {
              alert('There were errors:\n'+strErrors);
           }
  
         }
  
  &lt;/script&gt;
  </code></pre>