You are here: Home // Design and Programming // Solution: Setting a required field in a drop down menu in ColdFusion

Solution: Setting a required field in a drop down menu in ColdFusion

There may be another way in more recent versions but in earlier versions, to require the user to pick an answer on a form, simply do this…

Somewhere between the <form> and </form> tags (I usually put it at the top to eliminate confusion), place

<input type="hidden" name="nameoffield_required"
value="Must select an answer. Please go back to
continue.">

Then, in your form, as usual, create a drop down menu like this:

<SELECT name="nameoffield" size="1">
<OPTION selected value="">Please Select</OPTION>
<OPTION value="Yes">Yes</OPTION>
<OPTION value="No">No</OPTION>
</SELECT>

If they don’t pick anything, it will throw an error and give them a the message you placed in the first part above.

It’s a simple way to validate the required fields on your form.

Tags:

Leave a Reply

Copyright © 2011 Take My Ideas. All rights reserved.
Designed by Theme Junkie. Powered by WordPress.