View Full Version : Drop Down List Validation

08-08-2008, 10:49 AM
Hi im trying to validate a simple dropdown list with 3 options.

What I want to do is if the user clicks the submit button and option one is still chosen, then I want to alert them to choose either option 2 or 3 before proceeding.

Option 1 = Please Choose Time Slot?
Option 2 = 9am-1pm
Option 3 = 1pm-5pm

Hope you can help,


08-08-2008, 11:26 AM
Onsubmit of the form call a function like

<script type="text/javascript">
function validate(){
var mymenu=document.getElementById(mymenu'')
alert("please choose one") ;
return false;


<select ... name="mymenu" id="mymenu">
<option value="">Please Choose Time Slot?</option>
<option value="1">9am-1pm</option>
<option value="2">1pm-5pm</option>

08-08-2008, 12:02 PM

var mymenu=document.getElementById(mymenu'')

Should be:

var mymenu=document.getElementById('mymenu')

But, the main reason of my response is to highlight that you should return validate function. So as what abduraooft say, call it onsubmit event, and don't miss highlighted:

<form action="#" method="#" onsubmit="return validate()">

Hope that makes sense.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum