Input file type as read-only

Asked

Viewed 49 times

1

I am trying to set as read-only an input file type when clicking on Ubmit, but the way below did not work. Any suggestions?

<script>
$(document).ready(function() {
    $("#salvar").on('click', function() {
       $('#arquivo').prop('readonly', true);
    });
});
</script>

2 answers

1

Change the property readonly for disabled.

<script>
$(document).ready(function() {
    $("#salvar").on('click', function() {
       $('#arquivo').prop('disabled', true);
    });
});
</script>

https://jsfiddle.net/51emkmg2/

  • Thanks for the help, but this way it "loses" the file and the same won’t even go to the next screen. I’m testing a . Hide().

1

To disable an input-file use the property disabled

Example in Javascript

document.getElementById("myFile").disabled = true;

Example with jQuery

$('myFile').prop('disabled', true);
  • Thanks for the help, but this way it "loses" the file and the same won’t even go to the next screen. I’m testing a . Hide().

Browser other questions tagged

You are not signed in. Login or sign up in order to post.