You need to sign in to do that
Don't have an account?
Stefano Amenta
Disable upload button in VF page
hi,
I have a page where the user is required to upload 2 attachments.
What's the best approach to disable the Upload button if the user didn't load 2 attachments?
Thanks.
I have a page where the user is required to upload 2 attachments.
What's the best approach to disable the Upload button if the user didn't load 2 attachments?
Thanks.
<apex:page controller="UploadFilesController"> <apex:sectionHeader title="Upload Work Permit"/> <apex:form enctype="multipart/form-data" id="form"> <apex:pageBlock title="Document"> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockButtons > <apex:commandButton action="{!insertAttachmnet}" value="Upload"/> <input type="button" class="btn" value="Cancel" onclick="window.location='/{!CurrentVisaId}'" /> </apex:pageBlockButtons> <apex:pageBlockSection showHeader="false" columns="1" id="block1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Document" for="file1"/> <apex:inputFile value="{!Attachment1.body}" filename="{!Attachment1.name}" id="file1"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Document" for="file2"/> <apex:inputFile value="{!Attachment2.body}" filename="{!Attachment2.name}" id="file2"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> <script> if({!IsCompleted}) { window.location='/{!CurrentVisaId}'; } </script> </apex:form> </apex:page>
Below is the sample code , try to change according to your requirements.
Refer below link.
https://salesforce.stackexchange.com/questions/89489/show-error-message-in-visualforce-page-if-no-file-was-uploaded-by-user
Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.
Best Regards,
Sandhya
thanks for that.
Actually, I already have an error message showing up (it's defined in my controller).
My request was more about disabling the Upload button if the user didn't select 2 files. For example, the button is unclickable if 2 files have not been chosen.
Do you think it's possible?