Placeholder Is Not Working In Ie9
I am salesforce (SFDC) developer. In my visualforce page for input box I am using placeholder code.
Solution 2:
if(navigator.appVersion.match(/MSIE [\d.]+/)){
$(document).find("input[placeholder]").each(function(){
if($.trim($(this).val()) == ""){
$(this).val($(this).attr("placeholder")).addClass('placeholder');
}
$(this).on("focus",function(){
$(this).hasClass('placeholder') ? $(this).val('').removeClass('placeholder') : false;
}).on("blur",function(){
$(this).val() == '' ? $(this).val($(this).attr("placeholder")).addClass('placeholder') :false;
});
});
}
Solution 3:
A little simpler answer worked for me not being very trusting of Regex (my downfall)
functionsetPlaceHolderForIE9() {
var pos = window.navigator.userAgent.indexOf("MSIE");
if (pos > 0) {
if (window.navigator.userAgent.substring(pos + 5, window.navigator.userAgent.indexOf(".", pos)) < 10) {
//alert($("input[placeholder]").val($("input[placeholder]").attr("placeholder")));
$("input[placeholder]").each(function () {
$(this).val($(this).attr("placeholder"));
});
$("input[placeholder]").click(function () {
if ($(this).val() === $(this).attr("placeholder")) {
$(this).val('');
}
});
$('input[placeholder]').blur(function () {
if ($.trim($(this).val()).length === 0) {
$(this).val($(this).attr("placeholder"));
}
});
}
}
}
Post a Comment for "Placeholder Is Not Working In Ie9"