Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placeholder is not working properly in all browsers [duplicate]

Tags:

html

css

Possible Duplicate:
How do I get placeholder text in firefox and other browsers that don't support the html5 tag option?

I have created a login popup box and I used placeholder to show the input field name, but in other browsers like IE9, IE8 and even IE10 is not showing placeholder text in the input.

How can I resovle this issue? Is there any other way to fill the input field?

<input name="username" type="text" value="" placeholder="Username" />
like image 778
Muzammil Hussain Avatar asked Oct 07 '22 22:10

Muzammil Hussain


2 Answers

As OEZI said it's not supported in all browsers.

try this instead

<input name="username" type="text" value="" onfocus="if (this.value == 'Username') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Username';}" />
like image 104
Salil Momin Avatar answered Oct 10 '22 23:10

Salil Momin


placeholder is part of the new HTML5-features wich isn't fully supported by all browsers till now. for more information, please check:

  • http://caniuse.com/#search=placeholder (more html5/css3-features: http://caniuse.com/)
  • http://wufoo.com/html5/attributes/01-placeholder.html (more html5-features: http://wufoo.com/html5/)

EDIT:
if you're using jQuery, there's this little plugin to add support for all browsers down to IE6.

like image 20
oezi Avatar answered Oct 10 '22 21:10

oezi