Skip to main content
Inspiring
February 25, 2010
Question

Is there a way to validate CFSELECT in CFFORM?

  • February 25, 2010
  • 2 replies
  • 2137 views

Hi,

I'm using CFFORM and using CF's own built in validation for all fields.  The required fields are valided and if they are left blank, the javascript pop up prevents the form from getting submitted.  It does not work with cfselect however.  It lets the form get submitted even if nothing is selected in the cfselect.  Why does does the validation skip over cfselect?  Is there a solution?

Thanks!

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
February 28, 2010

jenn wrote:

Hi,

I'm using CFFORM and using CF's own built in validation for all fields.  The required fields are valided and if they are left blank, the javascript pop up prevents the form from getting submitted.  It does not work with cfselect however.  It lets the form get submitted even if nothing is selected in the cfselect.  Why does does the validation skip over cfselect?  Is there a solution?

Yes, there is a compromise solution, of sorts. Set cfselect's size attribute to 2.

Inspiring
March 2, 2010

Personally, I think that is just moving the confusion from developer to user ;-)  So I would use a custom function (or fix the validation scripts) instead.  But someone did submit a bug for this issue and it is listed as "fixed". Though not in my version ..

http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=80682

Inspiring
February 25, 2010

How does one select nothing in a select control?  There's always one item selected, even if its value is an empty string...

I think the case more here is that having a "requiredness" attribute on a <cfselect> tag is somewhat redundant / meaningless.

--

Adam

Inspiring
February 25, 2010

I note that if the <cfselect> is a multiple=true one, in which event one can select nothing, then the required setting works as one would expect.

--

Adam