Drop-down box - disallow first item

C

Cheryl

I have a form with a drop-down list, and I'd like to set
up client-side validation so that the person has to select
something other than the first item, Select Department. I
don't want to use FrontPage's webbot validation. Can
someone suggest how to do this? I've tried:

Sub send_onclick
Dim MyForm
Set MyForm=FrontPage_Form1

if RTrim(MyForm.fldDepartment.Value)="" then
msgbox "Enter a Department in the Department field."
MyForm.fldDepartment.focus
Exit Sub
end if

MyForm.Submit

End Sub

But this doesn't work. The msgbox pops up whether or not
an item is selected.

I've also tried:

if RTrim(MyForm.fldDepartment.Value)="Select Department"
then
msgbox "Enter a Department in the Department field."


This doesn't work either.

Any suggestions? Thanks for your help.
 
J

jon spivey

Hi Cheryl,
Javascript would be better for this - it works cross-browser. Something like
<script type="text/javascript">
function checkForm(f){
var s = f.something;
if(s.selectedIndex==0){
alert("Your Error Message");
return false;}
return true;}
</script>
<form onsubmit="return checkForm(this)">
<select name="something">
<option value="">choose an option</option>
<option value="option1">Option One</option>
etc
 
J

jon spivey

Is there something I missed? What happened to the storefront link in your
sig :)

Jon
 
Top