You can do server side validation and it will catch the errors, BUT it does NOT
pop up a javascript box like the inline required="yes" feature does. What it
does is loads a blank page with a plain gray box and it has your message.
What you have to do is to put in your select field, then add two hidden fields.
The name of each MUST match the name of your select box field. Then, to that
name you append, "_" and the command you want. For this issue, your first
field has "_required" added to the name, and for the second hidden field, you
add "_cfformnoblanks". The noBlanks catches the first value, which is blank.
Note that in my code below, I have an error message in each hidden field (as
the documentation states). Both messages get displayed in the ugly gray box.
Here is the code:
<cfselect id="survey1" name="survey1" required="yes" message="Please select a
response for question one." validate="noblanks">
<option value="">Select...</option>
<option value="Strongly Disagree">1= Strongly Disagree</option>
<option value="Disagree">2= Disagree</option>
<option value="Neutral">3= Neutral</option>
<option value="Agree">4= Agree</option>
<option value="Strongly Agree">5= Strongly Agree</option>
</cfselect>
<input type="hidden" name="survey1_required" value="You must answer.">
<input type="hidden" name="survey1_cfformnoblanks" value="Please select a
response for question one.">
I found all this stuff in the LiveDocs here:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000161.htm
PS - I tried to be a hack and entered in ' validate="noblanks" ' into my
cfselect tag hoping that would do the same thing, just tricking CF into writing
the JS to have the pop up box. Sadly, this does not work.
You can also use IsValid or CFPARAM as outlined on this page to make a custom
solution:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000161.htm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:211899
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54