I have an asp.net web form with some read only fields. My issue is that if the user selects the read only textbox and presses the backspace to try and delete the content in the textbox, it goes back a page in the form. I am using IE 11 and can't seem to find a working solution for this issue. Could someone provide me with some advice as to how to resolve this issue?
Asked
Active
Viewed 606 times
0
-
Perhaps take a look at this post? http://stackoverflow.com/questions/533867/whats-the-best-method-for-forcing-cache-expiration-in-asp-net – Stephen Sugumar Oct 21 '14 at 19:35
1 Answers
1
You'll want to prevent the keydown
event for readonly
inputs. Try the following
var inputs = document.querySelectorAll('input[readonly]');
for (var i=0; i<inputs.length; i++) {
inputs.item(i).onkeydown = function(e) {
if (e.which === 8) return false;
};
}
Note that 8
is the keycode for BACKSPACE.

styfle
- 22,361
- 27
- 86
- 128