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
Which built-in method calls a function for each element in the array?
What are different types of popup boxes available in javascript?
How much does a javascript developer make?
what is function of stdio.h
What is webpack used for?
How to port a GUI application onto Web
How to create an object in javascript?
How can an HTMLCollection be traversed?
What are decodeuri() and encodeuri() functions in javascript?
How will you explain closures in javascript? When are they used?
List html dom mouse events?
What is scope chain in javascript?
How can you get the total number of arguments passed to a function?
What is let keyword in typescript?
why can't we call a static method from a non-static method