...

View Full Version : Combox Question



jason_kelly
12-20-2011, 04:47 PM
Hi There,

I need your help.

What would be the Javascript code,

to check a if a selection has been made in a particular combox? and if a selection has not been made, to alert the user that they must select a value from the drop down box.

Much thanks and appreciation for all your help.

Cheers,

Jason

chump2877
12-20-2011, 05:00 PM
something like the following:


<form onsubmit="return validate(this);">
<select>
<option value="default">select a value</otion>
<option value="sdasdf">sdasdf</otion>
<option value="sdasdf">sdasdf</otion>
<option value="sdasdf">sdasdf</otion>
</select>
<input type="submit" value="submit" />
</form>

<script type="text/javascript">
function validate(formObj)
{
if (formObj.getElementsByTagName('select')[0].value == 'default')
{
alert('you must select a value from the drop down menu');
return false;
}
return true;
}
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum