Skip to content Skip to sidebar Skip to footer

Stop Ie Users Typing Into The File Upload Input

My testers have discovered that if you type free text into a file upload input then none of the buttons on the page work until that text is removed (so the page cannot be submitted

Solution 1:

As per @Jer's suggestion, I was able to prevent input into the file upload without breaking any of the other functionality by handling keypress events on the upload. Using jQuery:

$(document).ready() {
    $('input:file').keypress(function() {
      returnfalse;
    });
}

Solution 2:

I'm not sure if this would work as expected, but have you tried: <input readonly="readonly">

Solution 3:

The accepted answer is perfectly fine for all the existing file controls.

But in most of the practical situations, we provide functionality to add more file controls on the fly so that users can select more than one file.

Key for the solution in this case was the .live function.

The solution will be as follows:

$('input:file').live('keypress', function() { returnfalse; });

Post a Comment for "Stop Ie Users Typing Into The File Upload Input"