IE9 placeholder not show workaround (contains multiple password boxes)

Source: Internet
Author: User

Compatible with IE9 placeholder
function Isplaceholder () {
var input = document.createelement (' input ');
Return ' placeholder ' in input;
}
if (!isplaceholder ()) {//does not support placeholder using jquery to complete
$ (document). Ready (function () {
if (!isplaceholder ()) {
$ ("input"). Not ("input[type= ' password ')". each (//Exclude Input binding event Password box
function () {
if ($ (this). val () = = "" && $ (this). attr ("placeholder")! = "") {
$ (this). Val ($ (this). attr ("placeholder"));
$ (this). focus (function () {
if ($ (this). Val () ==$ (this). attr ("placeholder")) $ (this). Val ("");
});
$ (this). blur (function () {
if ($ (this). val () = = "") $ (this). Val ($ (this). attr ("placeholder"));
});
}
});
Special handling of the Password box 1. Create a text box 2 to get focus and lose focus when switching
$ ("input[type= ' password ')". each (
function () {
var Pwdfield = $ (this);
var pwdval = pwdfield.attr (' placeholder ');
Pwdfield.after (' <input class= ' login-input "type=" text "value= ' +pwdval+ ' autocomplete=" off "/> ');
var Pwdplaceholder = $ (this). Siblings ('. Login-input ');
Pwdplaceholder.show ();
Pwdfield.hide ();

Pwdplaceholder.focus (function () {
Pwdplaceholder.hide ();
Pwdfield.show ();
Pwdfield.focus ();
});

Pwdfield.blur (function () {
if (pwdfield.val () = = ") {
Pwdplaceholder.show ();
Pwdfield.hide ();
}
});
})
}
});
}
End

IE9 placeholder not show workaround (contains multiple password boxes)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.