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)