Most of us have issues with Coldfusion CFSELECT Validation i.e. form submits even though he didnt select an entry from drop down list and you have validation in CFSELECT . Here is the solution to this issue.
1. The validation works only if you have size attribute of cfselect set to a value greater than 1.
Here is my code that works
<cfselect name="sec_question" required="yes" message="You must select a security question to reset your password." size="2">
<option value="1">What is your mother's maiden name?
<option value="2">In what city were you born?
<option value="3">What is the title of your favorite book?
<option value="4">What is your favorite pet's name?
</cfselect>
2. Here are some observations
a. I didnt require selected="" attribute inside cfselect
b. I didnt require Please select a value i.e. with a space or without space(either way, I tried and it didnt work)
So try this and I am sure you wont be dissapointed. It took me a while to figure it out and I tried different options before I succeeded.
My post can also be found at Adobe CF docs
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000331.htm
or
http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000331.htm
Let me know if it doesnt work or if you have a question.
Friday, March 07, 2008
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment