5

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" />
Community
  • 1
  • 1
Muzammil Hussain
  • 91
  • 1
  • 1
  • 7

3 Answers3

2

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';}" />
Salil Momin
  • 361
  • 3
  • 11
  • 2
    Default values and placeholders are **not** equivalent. – Quentin May 04 '12 at 11:05
  • as Quentin said this would send the "placeholder"-text as value on form submission wich isn't what html5-placeholder do, so it might not work or need additional checking on submission (if it's a required field for example - with this code, the input isn't empty when the "placeholder" is shown) – oezi May 04 '12 at 11:18
  • 1
    yes I know but it's not that big deal. you can easily handle it. – Salil Momin May 04 '12 at 11:43
1

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

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

oezi
  • 51,017
  • 10
  • 98
  • 115
1

Placeholder is not supported by IE8 till now. You may use

<input type="text" name="username" onfocus="if(this.value=='Username') this.value='';" onblur="if(this.value=='') this.value='Username';" />
Jhilom
  • 1,028
  • 2
  • 15
  • 33
  • 2
    Default values and placeholders are **not** equivalent. – Quentin May 04 '12 at 11:05
  • as Quentin said this would send the "placeholder"-text as value on form submission wich isn't what html5-placeholder do, so it might not work or need additional checking on submission (if it's a required field for example - with this code, the input isn't empty when the "placeholder" is shown) – oezi May 04 '12 at 11:18