Coldfusion flash form validate or disable

Posted by Dark Training on July 27, 2009 tags: | coldfusion

One of the problems with flash forms in Coldfusion (CFFORM) is that you cant use javascript validation.

In the simple example I show below, here is how you can disable a button until a user checks a box

<cfform format="flash" METHOD="post">
<cfinput name="myCheckbox" type="checkbox"
label="I will obtain and maintain documented approval prior to my departure."
enabled="true"
required="yes"
onclick="submitBtn.enabled=myCheckbox.selected;"/>

<cfinput type="Submit" name="submitBtn" value="Submit" enabled="false">
      
</cfform>

Here is how you could hide a text box after a user clicks on a text feild

<cfinput type="text" label="Time (hh) in 24 hour format [0-24]:[00-59]" name="time" width="50" onChange="time_sub.enabled=true;text_1.visible=false;" validate="range" range="1,24" message="Must be from 1-24" maxlength="2">

<cfformgroup type="horizontal">

<cfinput type="submit" name="time_sub" value="Submit" enabled='false'>

<cfinput type="text" value="You must enter a time" visible="true" name="text_1" readonly="yes" width="200">

</cfformgroup>

Hope this helps some one else, I know it took me some work to figure out