You can also use the placeholder.js script that is available here at github
This script will insert the placeholder text as textbox text in a form, and remove it if user starts typing text.
Not exatly the same as the placeholder-look as that text will still remain when user is typeing underneath. But this is good enough I think since older browsers should be a little punished :-)
Assumes that you are using jquery, I always do nowadays...
Just add the following into your html page, and all should look fine!
<!--[if gte IE 10]>
<script type="text/javascript">
$(document).ready(function () {
fixplaceholder();
});
</script>
<![endif]-->
<script type="text/javascript">
function fixplaceholder() {
if ($.browser.msie) {
$('input[placeholder]').each( function () {
var input = $(this);
/* if postback, we dont want to overwrite the value! */
if($(input).val() != '')
return;
$(input).val(input.attr(' placeholder'));
$(input).focus(function () {
if (input.val() == input.attr('placeholder')) {
input.val('');
}
});
$(input).blur(function () {
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.val(input.attr(' placeholder'));
}
});
});
}
}
</script>
Inga kommentarer:
Skicka en kommentar