Yes Placeholder is not supported by IE 9. But you can look around to some alternative like javascript to achieve this very easily
<input type="text" placeholder="test" value="placeholder text"
onfocus="if (this.value=='placeholder text') this.value = ''" onblur="if (this.value=='') this.value = 'placeholder text'"/>
But you need to take care while using this approach as this approach setting the value
of textbox
. So when you will retrieve it, you will get the value. So whenever you will use it, you need to check for the placeholder value.
Your function would be like this
function ClickYes() {
// for modern browsers
$('#txtMsg').attr('placeholder', 'Tell me more');
// for older browsers
$('#txtMsg').val('Tell me more');
$('#txtMsg').css('color','#CCC');
}
Now you need to handle the focus
and blur
event to make it complete like this
$(document).ready(function () {
$("#txtMsg").focus(function () {
if ($(this).val() == 'Tell me more') {
$(this).val('');
$(this).css('color', 'black');
}
});
$("#txtMsg").blur(function () {
if (!$(this).val()) {
$(this).val('Tell me more');
$('#txtMsg').css('color', '#CCC');
}
});
});
Js Fiddle Demo
Js Fiddle Demo 2