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
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / upendar
<html>
<head>
<script type="text/javascript">
function validateform(){
var selObj =
document.getElementById('firstDrDn').selectedIndex;
if(selObj == 0)
{
alert("please select item from first list.");
document.getElementById('firstDrDn').focus();
return false;
}
return true;
}
</script>
</head>
<body>
<h2> Choose An Item From The Drop Down Menu: </h2>
<select name="item" id="firstDrDn">
<option value="0"> Select </option>
<option value="1">Bananas</option>
<option value="2">Mangoes</option>
</select>
<select name="item" id="secondDrDn"
onclick="validateform()">
<option value="0"> Select </option>
<option value="1">Apples</option>
<option value="2">Oranges</option>
</select>
</body>
</html>
| Is This Answer Correct ? | 0 Yes | 0 No |
Are all javascript variables global?
What is webassembly good for?
Entire content of a JavaScript source file in a function block?
How to convert json string to object?
What does 3+4+"7" evaluate to?
How do I enable javascript on google?
How to reload a page using JavaScript?
If you need to hide the javascript code from the older browser versions, how will you perform it?
Should I learn java first or javascript?
Write the code for adding new elements dynamically?
What is context in javascript?
how can we generate alert message without referashing page in asp.net with language vb.net and script use in java script .means with out referash the page message in java alert