Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop-Down Validation

Status
Not open for further replies.

jdmilton

Technical User
Oct 30, 2001
3
US
I want to do some server-side validation on a drop-down list in a form. The first item on the list is called "select One". When they submit the form, if they have not selected a name (it still say's (Select One") I want a message to tell them they have to select a name. Can anyone help?
 
Hi there,
On the page you are submitting to, you can do an error check, something along the lines of:

<cfif #trim(form.dropdown)# is &quot;Select One&quot;><cfinclude template=&quot;oops.cfm&quot;><cfabort></cfif>

Your oops page can prompt them to let them know they must select an option from the list and you could create a back button to return them to the form.

Or
<cfif #trim(form.dropdown)# is &quot;Select One&quot;>
You must select an option from the list.
<cfelse>
<!--- Complete the rest of the page --->
</cfif>

Of course, replace &quot;dropdown&quot; with the actual name of the form variable.

Hope that helps!
Jami
 
You might also try Javascript as a way to do preliminary form validation. You should use Jami's example as well, though, for people who slip through the cracks.

See faq216-1165 for the Javascript code. Enjoy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top