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 are ‘settimeout()’?
What is the difference between registerclientscriptblock and registerstartupscript?
How do I retrieve a cookie with a given name using a regular expression?
How do I activate javascript on my phone?
What do mean by NULL in Javascript?
What is difference between array.splice() and array.slice() method in javascript?
Do you need to declare variables in javascript?
How to set the cursor to wait in JavaScript?
What is a name function in javascript & how to define it?
What are nodes in javascript?
What is lazy loading in javascript?
Do I need javascript enabled?
What is an object in javascript, give an example?
Can you explain how inheritance works in javascript?
What are javascript properties?