function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Anyway to disable a forms submit button when inputfile is used?

As you may know, forms that have inputfile tags can't use status indicators.  Also, buttons that submit forms where files are uploaded can't have javascript that runs onclick AND have apex methods called. 


So, how do you have a button that gets disabled upon click while files upload?  I ask because if a user isn't patient and clicks submit a 2nd time, they will get an error and have to start over.


Thanks for any ideas or examples.


what about onsubmit event inside the <apex:form tag?




I tried that and it calls the onsubmit javascript but then the apex method (to save the record and attach the files) doesn't get called.


I've tried this code 

<apex:page controller="pruebaForm">
  <apex:form onsubmit="alert('hello'); return true;">
    <apex:inputFile value="{!whatever}" />
    <apex:commandButton action="{!action}" value="Send"/>


And the javascript works :S, and after that, the method action (that the only thing that does is to redirect me to the homepage) also works


SeAIVa - thanks for the reply.


I forgot to mention that my form is a wizard that uses mutiple output panels with buttons.  These output panels get rendered, then once completed / validated they are hidden and the other panels (one at a time) get rendered.


Per salesforce support and best practices, this is all done in one form.


When I tried your example, the first output panel failed to hide and the 2nd failed to appear - it just depressed the button.


I even tried breaking up the output panel with the input files into its own form and the behavior was the same.