Skip to main content
March 5, 2010
Question

unselecting item in cfselect

  • March 5, 2010
  • 1 reply
  • 466 views

Simple question here...have a cfselect tag bound to a cfquery (see below).  I want the tag to appear unselected so that the user is required to select an item.  The problem is that no validation ever occures apparently because the 1st item is already selected.

<cfselect

name="select1" query="qryHair" display="description" value="code" queryPosition="Below" required="yes" message="You must select a value here.">
<option value="">select</option>
</cfselect>

So what's the trick?

    This topic has been closed for replies.

    1 reply

    Inspiring
    March 5, 2010

    Unfortunately, the required attribute of cfselect doesn't work unless you've marked the particular cfselect as a multiple select list. You'll need to either edit the cfform.js file or roll your own JavaScript to validate it on the client side.

    March 5, 2010

    Thanks. I wrote a little javascript snippet and got it to work just fine.