Stop IE users by typing login to download files

My testers found that if you enter free text into a file for downloading, then none of the buttons on the page will work until the text is deleted (therefore, the page cannot be sent).

I can reproduce this with the following ASPX code (without code):

<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:FileUpload ID="fuTest" runat="server" />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
      </div>
    </form>
  </body>
</html>

(Please note: I did not attach any handlers to the page, despite this, the page is sent when the submit button is pressed, only if the text is not entered in the download text box)

Is there a way to prevent users from entering free text in a file upload control? It seems that this is possible only in IE - Firefox and Chrome, because of which the text is not entered in the input fields of the download.

, /, , .

?

+3
3

@Jer - , keypress . jQuery:

$(document).ready() {
    $('input:file').keypress(function() {
      return false;
    });
}
+5

, , , : <input readonly="readonly">

+2

.

, .

The key to solving in this case was the .livefunction .

The solution will look like this:

$('input:file').live('keypress', function() { return false; });
+1
source

Source: https://habr.com/ru/post/1737361/


All Articles