I am having issues with making sure users select an option from a select
box... here is my code
function checkit(){
if (document.postdata.phonenumber == ""
{
alert("Please enter a Phone Number"
;
return false;}
if (document.postdata.request[document.postdata.request.selectedIndex].value
== ""
{
alert("Please Select a Request"
;
return false;}
}
<form name=postdata action=?action=add method=post onsubmit='return
checkit()'>
<input type=text name=phonenumber>
<select name=request>
<option value=1>Send manual</option>
<option value=2>Duplicate Product</option>
<option value=3>Did not order</option>
</select>
<input type=submit>
</form>
can someone help me figure this out. I believe it is because
document.postdata.request is undefined until an option is chosen but I don't
know how to fix that.
box... here is my code
function checkit(){
if (document.postdata.phonenumber == ""
alert("Please enter a Phone Number"
return false;}
if (document.postdata.request[document.postdata.request.selectedIndex].value
== ""
alert("Please Select a Request"
return false;}
}
<form name=postdata action=?action=add method=post onsubmit='return
checkit()'>
<input type=text name=phonenumber>
<select name=request>
<option value=1>Send manual</option>
<option value=2>Duplicate Product</option>
<option value=3>Did not order</option>
</select>
<input type=submit>
</form>
can someone help me figure this out. I believe it is because
document.postdata.request is undefined until an option is chosen but I don't
know how to fix that.