I have a simple input field:
and some JQuery code:
$(e.curre
Okay, this is bizarre: If you make the field read-only while it has focus, IE11 seems to go a bit bonkers, and one of the ways it goes bonkers is to let you keep modifying the field while the cursor is there — with some keystrokes, but not others. Here's an example: Fiddle
$("#myInput").one("click", function(e) {
$(e.currentTarget).prop('readonly', true);
display("e.currentTarget.readOnly: " + e.currentTarget.readOnly);
});
$("#myInput").on("keydown", function(e) {
display("e.currentTarget.readOnly: " + e.currentTarget.readOnly);
});
function display(msg) {
$("").html(String(msg)).appendTo(document.body);
}
Adding this line before setting readOnly
fixes it (fiddle):
$(e.currentTarget).blur();
Side note: You don't need jQuery to set the readOnly
property, just:
e.currentTarget.readOnly = true; // Note the capital O