> Can anyone suggest a technique for disabling the button
> after the form has passed validation? (The server code that
> runs after gets into trouble when impatient users do
> multiple clicks.)

I had to do this on a credit card processing form a while back.  The
form was identified as "ccForm" (in the CFFORM tag, name and id
attributes) and the following JavaScript was placed just below the
closing CFFORM tag.  Just replace "ccForm" anywhere it shows up below
with the name of your form:

<script type="text/javascript">
        // Override the built-in CF error handler.
        document.getElementById('ccForm').onsubmit = doValidate;

        // Define our own validation function.
        function doValidate() {
                returnValue = _CF_checkccForm(document.forms.ccForm);
                if (returnValue==true) {
                        $('#btnSubmit').css("display", "none");
                        $('#processingNotice').css("display", "block");
                        return true;
                } else {
                        return returnValue;
                }
        }
</script>

Essentially what this does is override the default onsubmit function
that ColdFusion attaches to the form with a custom function.  That
function then calls the default and if it passes, uses jQuery to hide
my submit button and show a "processing" div that was previously
hidden.  You can just as easily disable the button if desired.  If the
validation fails, we simply return CF's validation result and do not
change the button status, thus allowing multiple clicks and only
changing it once validation passes.


-Justin Scott

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:348508
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to