Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JWEC opened this issue Feb 18, 2014 · 9 comments
Open

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

JWEC opened this issue Feb 18, 2014 · 9 comments

Comments

@JWEC
Copy link

JWEC commented Feb 18, 2014

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;
    }
@jamesallardice
Copy link
Owner

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.

@JWEC
Copy link
Author

JWEC commented Feb 19, 2014

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.

@ses4j
Copy link

ses4j commented Apr 23, 2014

Was a change made here?

@chakravarthy88
Copy link

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

elem.type = "text"

@ghost
Copy link

ghost commented Oct 10, 2014

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

@Lrelia
Copy link

Lrelia commented Mar 27, 2015

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

@royJang
Copy link

royJang commented Jul 29, 2015

plz fix it!

@MinimalistYing
Copy link

It seems that nobody maintain this repository at all.

@laoruiwen
Copy link

T_T please fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants