title: two html onsumbit validation with java
body: <p>I have these two java function for validation text input field and drop down selection. I am trying to combine both validation onSubmit. it didn't work when I put both validation together but it work when I put one at the time.</p>
  
  <pre><code> function validname(fld) {
   var error = "";
   var valid = /^[a-zA-Z0-9\-]*$/; 
  
   if (fld.value == "") {
      fld.style.borderColor = '#ff0000'; 
      document.getElementById('name').style.color = "#ff0000";
      error = " - Invalid device name..\n";
   } else if(valid.test(fld.value)){
      fld.style.borderColor = ''; 
      document.getElementById('name').style.color = "#000000";
   } else {
      fld.style.borderColor = '#ff0000'; 
      document.getElementById('name').style.color = "#ff0000";
      error = " - Invalid device name. \n";
   }
   return error;
    }
  
    function ValidateDropForm() {
      var isValidDropForm = true;
      var errorMessages = "";
  
      var e = document.getElementById('domain');
      if (e.options[e.selectedIndex].text == "--Select--") {
          document.getElementById('domainError').innerHTML = "- Domain name required.";
          isValidDropForm = false;
      } 
     if (!isValidDropForm) {
          //alert(errorMessages);
  
      }
  
       return isValidDropForm;
      }
  </code></pre>
  
  <p>this what I did..</p>
  
  <p>HTML
        <code>&lt;form action="" method="POST" onsubmit="return validateForm(this) &amp;&amp; ValidateDropForm()"&gt;</code></p>