You are viewing limited content. For full access, please sign in.

Question

Question

Disabling the File Upload button

asked on July 19, 2017

Hi Folks,

I have a form with a variable length table, with one column containing a File Upload field. Without going into too much detail, how do I disable the upload button using JS? I am currently using the following code:

 $(document).ready(function () { 
    
 updateTable(); 
  
 function updateTable() { //Change Read-Only attributes based upon Approval Status
   

         $('.cf-table-block tbody tr').each(function () {         

             var jobType = $(this).find('.drop input:checked').val(); 

             switch (jobType) { 

                case "Yes": 
                 
                     $(this).find('.ro input').attr('readonly', true); 

                     $(this).find('.ro select').attr('disabled', true); 
                 
                 	 $(this).find('.ro textarea').attr('readonly','readonly'); 
                 
                 	 return; 

               case "?": 
                                  
                     $(this).find('.ro input').attr('readonly', true); 

                     $(this).find('.ro select').attr('disabled', true); 
                 
                 	 $(this).find('.ro textarea').attr('readonly','readonly'); 

                     return; 
  
               
              default:  
                                 
                     $(this).find('.ro input').attr('readonly', true); 

                     $(this).find('.ro select').attr('disabled', true); 
                 
                 	 $(this).find('.ro textarea').attr('readonly','readonly'); 

                     return; 

             } 
         
         }); 

     }//end of function  
   
 });  
    

This works fine for all other field types (date, single / multiple lines and drop downs) which make up the table with the exception of the File Upload.  

All fields have been assigned the class ro. I don't want to hide the field as the approver needs to review the uploaded file but not be able to change or add to this field!

Thanks,

0 0

Replies

replied on July 19, 2017 Show version history

Try setting the "disabled" attribute on the button. It is an "input" element, but the read-only attribute your setting won't have the same effect on an input with the "button" type.

After that, you'll want to double check to make sure that it doesn't allow drag and drop uploads.

Then, test it to see if you also need to hide the X buttons next to the files so the user can't remove anything either.

1 0
replied on July 20, 2017

Thanks Jason, that allowed me to disable the file upload button which helps a lot.  

You were also right about drag & droping files. The label saying "drop files here" doesn't appear but files can still be added to disabled buttons. 

I could also use hide the X next to the files, by selecting the "Previous data and new rows with lookup lookup data will be read-only", but this disabled the option in all rows, rather than selected.  

0 0
replied on July 20, 2017

Disabling the "file" type input in that same field might help with dragging and dropping, but there's a lot of elements and events going on there so I'm not 100% sure how to get it to behave exactly the way you want.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.