hi i want validations for two dropdown lists in java
script.when user enter to second dropdown list by skipping
first dropdown list we should get alert box. please help me
very urgent
Answer Posted / sasi5586
<HTML><HEAD>
<TITLE>drop down validation</TITLE>
<script type="text/javascript">
function validateForm(){
if(document.ItemList.Item.selectedIndex==0)
{
alert("Please select item from first list.");
document.ItemList.Item.focus();
return false;
}
return true;
}
</SCRIPT>
</HEAD>
<BODY>
Please choose an item from the drop down menu:
<form name="ItemList" method="post" action="asp.html"
onsubmit="validateForm()">
<table width="100%" border="0">
<tr>
<td width="135">Choose a username: </td>
<td>
<select name="Item">
<option value selected> SELECT </option>
<option value>Apples</option>
<option value>Oranges</option>
</select>
<table width="100%" border="0">
<tr>
<td width="135">Choose a username: </td>
<td>
<select name="Item" onclick="validateForm()">
<option value selected> SELECT </option>
<option value>Apples</option>
<option value>Oranges</option>
</select>
<input type="submit" name="Submit" value="Submit">
</td></tr></table></form>
</BODY>
</HTML>
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
What is difference between java and javascript?
What is Number object in JavaScript?
How do you implement Ajax using hide() function in JQuery?
What is noscript tag?
What is the purpose of 'this' operator in JavaScript?
What is unobtrusive javascript?
Why extending array is bad idea?
What is the difference between ‘function declaration’ and ‘function expression’?
Can javascript code be broken in different lines?
What is difference between api and library?
How host objects are different from native objects in javascript?
Is javascript enabled on my computer?
What is a name function in javascript?
What does two exclamation marks mean in javascript?
What is the use of isNaN function?