IE 11 v11 does not respect “disabled” property on inputs on a single machine

拈花ヽ惹草 提交于 2019-12-13 04:36:02

问题


I support an asp.net web application using Jquery v3.3.1 which uses JavaScript to disable various inputs of type "text" or "date" using code like the following:

$('#id').prop('disabled',true);

When this bit of javascript is applied to an input of type "text" or "date" its appearance changes to greyed-out and a user cannot edit the contents of the input.

The problem is, when this page is viewed in IE 11 on one machine in our building the "disabled" property of inputs of type "text" or "date" is partially ignored. Hundreds of machines access this web page but only one machine is known to have this issue.

By "partially ignored" I mean that when the input's 'disabled' property is set true as in the code snippet above the input appears disabled, but the user is able to type values into the disabled input (any masks on the input are ignored; for example, date masks, or masks that limit inputs to integers).

On the bright side, these phantom values typed into the disabled input are also ignored; for example, if the input is of type "date" and the user enters the word "cat", no client-side validation error occurs, and when the form is posted back the value for the input is null, which is of course the desired state.

In sum, this is strictly a cosmetic problem. Functionally the page behaves the same on the problem machine as it does everywhere else.

I originally assumed that this problem was due to the problem machine having a version of IE that no other machine in our building had (v11.0.60). But after upgrading the problem machine and some other machines to IE 11.0.70 the problem still remains on just the problem machine. Other machines with the same IE 11.0.70 behave properly.

I've searched through the myriad IE settings, but cannot find anything different on the problem machine.

Is anyone else having this problem? Any hints on how to even debug an issue like this is much appreciated.


回答1:


IE 11 doesn't always follow the rules. If you switch it to:

$("#id").prop("disabled","disabled");

It will work in IE.

If you only want to run that code for IE 11 or lower, here is a way to do that from another good post. How to load a script only in IE



来源:https://stackoverflow.com/questions/51790522/ie-11-v11-does-not-respect-disabled-property-on-inputs-on-a-single-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!