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
 
C

clintonG

After two and a half years of giving it your best shot and hoping
things would change would you keep doing business with a
group of lying cheating rats?

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET (e-mail address removed)
URL http://www.metromilwaukee.com/clintongallagher/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top