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


Please Help Members By Posting Answers For Below Questions

Is array an object javascript?

465


What is the purpose of 'this' operator in JavaScript?

595


List html dom mouse events?

502


how to run the servlet in tomcat

1640


I am providing the Online& class room training on Worksoft Certify for SAP/HTML/JAVA using real time scenarios in a real time environment for a real time project, If any one is interested please get in touch with me on aimansaud@gmail.com

1021






What is difference between callback and promise?

443


Explain few difference between null, undefined or undeclared javascript variable?

481


What is scope chain in javascript?

492


How to submit a form using JavaScript by clicking a link?

535


Which built-in method returns the length of the string?

518


What does 3+4+"7" evaluate to?

469


What is callback in javascript?

479


How fast can you learn coding?

489


What does the delete operator do?

489


Define unescape() function?

520