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 / 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 |
Post New Answer View All Answers
20 Functions of Selenium with description and Examples.
What is the difference between firstChild and firstElementChild?
What is primitive data type in javascript?
List the comparison operators supported by javascript?
What is a framework programming?
How is it possible to get the total number of arguments that are passed to a function?
Why is object naming important to use in javascript?
What would be the result of 2+5+”3″?
What is the difference between var and let?
Where do you write javascript?
Can you have a function within a function in javascript?
How do you disable javascript?
Can you use javascript to hack?
How can you convert the string of any base to integer in JavaScript?
How to make elements invisible?