Placeholders.js icon indicating copy to clipboard operation
Placeholders.js copied to clipboard

IE8 placeholders for password (acceptable fix? optional fix?)

Open JWEC opened this issue 11 years ago • 9 comments

IE8 hides text of password. I rather think it should not show it at all as it is very confusing for the user. One can chose to remove password from validTypes array, but then it does not work for IE9 either.

My solution was to modify showPlaceholder like this to make a check if it was possible to change type of password to text.

I basicly moved to "set value" part to after the changeType was called. If changeType fails the method returns false instead and never sets the value.

function showPlaceholder(elem) {
        var type,
            maxLength,
            val = elem.getAttribute(ATTR_CURRENT_VAL);
        if (elem.value === "" && val) {

            // If the type of element needs to change, change it (e.g. password inputs)
            type = elem.getAttribute(ATTR_INPUT_TYPE);
            if (type) {
                elem.type = "text";
            } else if (elem.type === "password") {
                if (Utils.changeType(elem, "text")) {
                    elem.setAttribute(ATTR_INPUT_TYPE, "password");
                }
                else
                {
                    return false;
                }
            }


            elem.setAttribute(ATTR_ACTIVE, "true");
            elem.value = val;
            elem.className += " " + placeholderClassName;

            // Store and remove the maxlength value
            maxLength = elem.getAttribute(ATTR_MAXLENGTH);
            if (!maxLength) {
                elem.setAttribute(ATTR_MAXLENGTH, elem.maxLength);
                elem.removeAttribute("maxLength");
            }



            return true;
        }
        return false;
    }

JWEC avatar Feb 18 '14 15:02 JWEC

I am open to removing the password functionality when it is not supported (as you say that is easy to detect because the type attribute won't change). However I think it should be a configurable option and should probably work by splicing the password type out of the validTypes array at run time. I'll have a look into this for the next version which I hope to release within the next few days.

jamesallardice avatar Feb 19 '14 08:02 jamesallardice

I agree that opt-out is probably the best as it won't break current usage. Thanks for the fast feedback, it's a really useful polyfill.

JWEC avatar Feb 19 '14 10:02 JWEC

Was a change made here?

ses4j avatar Apr 23 '14 21:04 ses4j

In IE8 when i try to modify the type of the element the below line is throwing error

elem.type = "text"

chakravarthy88 avatar May 26 '14 05:05 chakravarthy88

could you fix this? let type=password also show placeholders

ghost avatar Oct 10 '14 09:10 ghost

I think this is really a big problem..hope someone fix it.

Lrelia avatar Mar 27 '15 02:03 Lrelia

plz fix it!

royJang avatar Jul 29 '15 11:07 royJang

It seems that nobody maintain this repository at all.

MinimalistYing avatar Jul 19 '17 01:07 MinimalistYing

T_T please fix it

laoruiwen avatar Aug 08 '19 01:08 laoruiwen