JavaScript Combo Box Validation

In this example we create a combo box of different technologies where if user select any technology and press the submit.

JavaScript Combo Box Validation

JavaScript Combo Box Validation

     

This application illustrates how to validate the combo box using JavaScript validation.

In this example we create a combo box of different technologies where if user select any technology and press the submit button then he/she successfully process the next step of the application but if user not select any technology then he/she got a alert message.

 

The Example is as follows:

 

Source Code of combo.html 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD>
  <TITLE>ComboBox Validation</TITLE>

  <script Language="JavaScript">
  function validateR(){
  var selectedCombobox=(comboForm.technology.value);
  if (selectedCombobox=="-1") {
  alert("Please Select Technology");
  return false;
  }
  return true;
  }
  </script>

  
 </HEAD>

 <BODY>
  <form name="comboForm">
  <select name="technology">
  <option value="-1">Select</option>
  <option value="JSP">Java Server Pages</option>
  <option value="Servlet">Servlet</option>
  <option value="PHP">PHP</option>
  <option value="ASP">ASP</option>
  </select>

  <input type="submit" value="submit" onclick="return validateR();">
  </form>
  
 </BODY>
</HTML>

 

Download Source Code