House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Validation of a select Menu using <cfselect>

  << Previous Post |  RSS |  Tree View |  Sort Oldest First |  Subscribe to this Group Next >> 

Validation of a select Menu using <cfselect>

> Your fix is great - if you control your own CF Server, but if Dave Watts 05/08/2008 12:24 PM
Thanks, Phillip -- Heather Harkins 05/08/2008 10:57 AM
I just found this posted by a user in the LiveDocs and it works great! Phillip Molaro 07/14/2005 04:12 PM
Make it <option value=""></option> Bryan LaPlante 02/15/2001 10:38 PM
try to change <option selected></option> Mak Wing Lok 02/15/2001 09:16 PM
Hi Everyone.  I am running into a problem validating a select menu John Cowie 02/15/2001 04:08 PM

05/08/2008 12:24 PM
Author: Dave Watts Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:911#304906 > Your fix is great - if you control your own CF Server, but if > you've got a client who's on a shared box, then you need > another work-around. No, you can just copy the existing JS files to your own directory, then use the SCRIPTSRC attribute of CFFORM. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Training: Adobe/Google/Paperthin Certified Partners http://training.figleaf.com/ WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers! http://www.webmaniacsconference.com/
05/08/2008 10:57 AM
Author: Heather Harkins Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:911#304853 Thanks, Phillip -- This is something that has irked me for years. Due to its limitations, I've never really used CFFORM extensively, but I thought I'd give it a go for a new project and hit this immediately. Your fix is great - if you control your own CF Server, but if you've got a client who's on a shared box, then you need another work-around. My charming husband has a solution: So, you take the SERIOUSLY FLAWED CFSELECT-generated validation function (called _CF_hasValue) and set it to a new variable, called _CF_hasValue_old. Then, you run through your NEW function, now called by the original one's name. If the function finds a select box of size 1 on the form, it will loop through the values until it finds one that is not only SELECTED but also has a VALUE (the latter little tidbit is NOT something that CF validation checks for. Ridiculous!). If it finds one, it breaks out of the function. Otherwise, it continues on and will returns false. On the other hand, if the field in question isn't a single-select, then the old CF Validating function will run. ** Caveat: this assumes that Adobe's not going to be changing the names of any functions with newer versions... ?? So use at your own risk. So, for example, I configured my form like this (using attribute "queryposition" to manage my valueles OPTION tag relative to my query output): <CFFORM... blah blah> <CFSELECT name="ThingID" required="Yes" size="1" queryposition="below"   message="Please make a Thing selection."          value="ThingID" query="qThingTypes" display="Things">   <OPTION>Please select a Thing Type</OPTION> </CFSELECT> <[SUBMIT]> </CFFORM> <SCRIPT> var _CF_hasValue_old = _CF_hasValue; _CF_hasValue=function(_b,_c,_d) {   if (_b.type == 'select-one')   {     var bSelected = false;     for (var i=0; i<_b.options.length; i++)     {       if (_b.options[i].selected == true && _b.options[i].value != '')       {         bSelected = true;         break;       }     }     return bSelected;   }   else     return _CF_hasValue_old(_b,_c,_d); } </SCRIPT> ================================================================== ----- Excess quoted text cut - see Original Post for more ----- htm
07/14/2005 04:12 PM
Author: Phillip Molaro Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:911#211914 I just found this posted by a user in the LiveDocs and it works great! What you need to do is to edit the javascript that the CF server writes so that it also checks for a null value (your value="" part of your first option item). This is a simple code change in a javascript template file.  Edit this file: C:\CFusionMX7\wwwroot\CFIDE\scripts\cfform.js Inside this file, modify line #73 this way: ORIGINAL: else if (obj_type == "SELECT") { for (i=0; i < obj.length; i++) { if (obj.options[i].selected) return true; } return false; } MODIFIED: else if (obj_type == "SELECT") { for (i=0; i < obj.length; i++) { if (obj.options[i].selected && obj.options[i].value != "") return true; } return false; } You may need to restart your coldfusion service, but otherwise this will work with the standard required="yes" method in your cfselect tag. Giving credit where credit is due: http://livedocs.macromedia.com/coldfusion/5.0/CFML_Reference/Tags91.htm
02/15/2001 10:38 PM
Author: Bryan LaPlante Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:911#4028 Make it <option value=""></option> ----- Excess quoted text cut - see Original Post for more ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm
02/15/2001 09:16 PM
Author: Mak Wing Lok Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:911#4015 try to change <option selected></option> to <option></option> ----- Excess quoted text cut - see Original Post for more ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm
02/15/2001 04:08 PM
Author: John Cowie Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:911#4001 Hi Everyone.  I am running into a problem validating a select menu using <cfform>. All of my <cfinput> tags are validating fine but the select menu doesn't seem to be working.   Here is the code that I am using.  If anyone can see what I am doing wrong I would appreciate the help. Thanks in advance John <cfform action="addrecord.cfm" method="POST"> <cfselect name="Status_Field" size="1" message="Please select a category" required="Yes"> <option selected></option> <option value="Member">Member</option> <option value="Non-Member">Non-Member</option> <option value="Student">Student</option> <option value="Educator">Educator</option> </cfselect> </cfform> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm
<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference