JavaScript Validation for DropDown Menu List?
>> Saturday, June 18, 2011
Drop Down List Validation
When click the submit button The image is shown below
The code is shown below:
If we doesn't select any Drop down menu the output is shown in below image
When click the submit button The image is shown below
The code is shown below:
<HTML><HEAD> <TITLE>Dropdown Validation</TITLE> <SCRIPT LANGUAGE="JavaScript"'> <!-- function validateForm(thisform){ if(document.ItemList.drpDown.selectedIndex==0) { alert("Please select an Item."); document.ItemList.drpDown.focus(); } return false; } //--> </SCRIPT> </HEAD> <BODY> Please choose an item from the drop down menu: <form name="ItemList" method="post" action="/bhaskar"> <table width="100%" border="0"> <tr> <td width="135">Choose a username: </td> <td> <select name="drpDown"> <option value selected>-- SELECT --</option> <option value>Apples</option> <option value>Oranges</option> </select> <input type="submit" name="Submit" onclick="validateForm(ItemList);return false;" value="Submit" > </td></tr></table></form> </BODY> </HTML>
If we doesn't select any Drop down menu the output is shown in below image
0 comments:
Post a Comment