Situation 1

Why is the placeholder selectable in a deactivated input[type="text"]?

<input name="minMax2" disabled="disabled" id="minMax2" type="text"  
                      placeholder="min. 100 / max. 200" min="100" max="200">

Situation 2

I've even have a weird situation where I can type text into the placeholder but this does happens if I click into a text field which is deactivated but because I've left another field and an attached change event did enable the datepicker.

Any idea? Did I miss something or is this a bug of Internet Explorer 10 and 11?

有帮助吗?

解决方案 2

I made a few changes to your jsfiddle from what I understand to be your problem. In your jsfiddle you included jQuery so I thought I would add to your script. I have just changed how you have declared disabled in your input and also made a change to your script so that it now removes the disabled attribute on focus.

$('#test3').prop("disabled", false).focus();

http://jsfiddle.net/a8ezd/3/

If you want to go further and make it so that the user can't even select the placeholder slightly when it's e.g. disabled then you could alter the user select in the css by adding the following with the appropriate browser prefix:

user-select:none; 

Example of that here:

http://jsfiddle.net/a8ezd/4/

其他提示

Looks like this is a browser behavior. As an alternative you can keep it enabled (style it appropriately as disabled if needed) and add attribute onfocus="this.blur()"

Here's your demo modified: http://jsfiddle.net/a8ezd/1/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top