Skip to main content
Known Participant
January 10, 2007
Question

Trying to make CFSELECT TAG required field

  • January 10, 2007
  • 3 replies
  • 598 views
Anyone know why the validation is not working?

<cfselect name="org" required="yes" validateat="server">
<option value="">Select Below</option>
<option value="test">Test</option>
<option value="test">Test1</option>
<option value="test">Test2</option>
</cfselect>
    This topic has been closed for replies.

    3 replies

    Participating Frequently
    January 10, 2007
    Easiest Way

    isn't the answer because cf ignores the "required" because there is a value in the list that was populated with the query..

    Next Easiest Way
    Not an answer that I can act on so it would be helpful if someone pointed me to an example so has some direction.

    Hardest Way
    Not an answer
    Inspiring
    January 11, 2007
    quote:

    Originally posted by: Ricky
    Easiest Way

    isn't the answer because cf ignores the "required" because there is a value in the list that was populated with the query..

    Next Easiest Way
    Not an answer that I can act on so it would be helpful if someone pointed me to an example so has some direction.

    Hardest Way
    Not an answer

    I learned to write javascript by buying the book, "Teach Yourself Javascript in 24 Hours" by SAMS publishing. Since it sounds like this is not one of your strengths, you might consider a similar approach.
    Inspiring
    January 10, 2007
    The concept of a required attribute of a cfselect tag is misleading at best because the field will always have a value when the form is submitted. It might not have the value you want, but it will have a value. There are three ways to handle this:

    Easiest Way
    Only include options that you want selected. In other words don't have this:
    <option value="">Select Below</option>

    Next Easiest Way
    Write code on your action page to handle values you didn't want selected.

    Hardest Way
    Write javascript on your form page to handle values you didn't want selected.
    Participating Frequently
    January 10, 2007

    The javascript for the cfselect has issues. I've got a blog entry on this (with a fix) at

    http://www.intersuite.com/client/index.cfm/2005/9/19/cfselect-mod
    Inspiring
    January 12, 2007