|
 |
asp_web_howto thread: asp form validation problem
Message #1 by "taherm@f... on Thu, 18 Oct 2001 10:42:27
|
|
i have a form with a list/menu in it
the options in the drop down are as follows
<select name="method">
<option value="0" selected>Please Select Delivery</option>
<option value="CITY" > CITY LINK </option>
<option value="Royal" > Royal</option>
</select>
i want the user to select any option before the form is submitted
so what i have done is
wrote onsubmit=verifydelivery() in the form
and now i want to write a javascript function that if the drop down value
is 0 then alert the user else rediriect the user to test.asp page
how can i do the above???
thanks
Message #2 by Roger Balliger <Roger@i...> on Thu, 18 Oct 2001 09:34:30 -0700
|
|
Try this:
<HTML>
<HEAD>
<script language=JavaScript>
function verify(method)
{
if (document.form1.method[method.selectedIndex].value == 0)
{
alert("You must select a Delivery option");
return false;
}
}
</script>
</HEAD>
<BODY>
<form action="" method=post name=form1 onSubmit="return verify(method)">
<select name="method">
<option value="0" selected>Please Select Delivery</option>
<option value="CITY" > CITY LINK </option>
<option value="Royal" > Royal</option>
</select>
<input type=submit>
</form>
<P> </P>
</BODY>
</HTML>
Roger
|
|
 |