Hi everybody, I'm trying to have validation in a jump menu.
So when you submit without selecting an option
alert("please select an option in the menu"
when an option has been selected
alert("Its good"}
Below is what is trying to do that but doesn't work.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"
if (restore) selObj.selectedIndex=0;
}
function feeed()
{
if (document.theform.menu1.value == ""
{alert("please select an option in the menu"}
else
{alert("Its good"}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="theform" method="post" action="" onchange="feeed";>
<p>
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option>please select</option>
<option value="opt1.htm">opt 1</option>
<option value="opt2.htm">opt 2</option>
<option value="opt3.htm">opt 3</option>
</select>
</p>
<p><input type="submit" name="Submit" value="Submit">
</p></form>
<p> </p>
</body>
</html>
So when you submit without selecting an option
alert("please select an option in the menu"
when an option has been selected
alert("Its good"}
Below is what is trying to do that but doesn't work.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"
if (restore) selObj.selectedIndex=0;
}
function feeed()
{
if (document.theform.menu1.value == ""
{alert("please select an option in the menu"}
else
{alert("Its good"}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="theform" method="post" action="" onchange="feeed";>
<p>
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option>please select</option>
<option value="opt1.htm">opt 1</option>
<option value="opt2.htm">opt 2</option>
<option value="opt3.htm">opt 3</option>
</select>
</p>
<p><input type="submit" name="Submit" value="Submit">
</p></form>
<p> </p>
</body>
</html>