Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-21-2012, 04:32 AM   PM User | #1
formdev1
New to the CF scene

 
Join Date: Sep 2012
Posts: 5
Thanks: 4
Thanked 0 Times in 0 Posts
formdev1 is an unknown quantity at this point
Placeholder......

Hi to all,

This is my first post.

I want to disappear the placeholder content "Username" as per the below code after mouse click on the text field. How to achieve this?
Below is the code for text field with placeholder.
Code:
<td><input type="text" name="fname" size="25" placeholder="Username"/></td>


Thanks....
formdev1 is offline   Reply With Quote
Old 09-21-2012, 05:23 AM   PM User | #2
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
Welcome to the forums formdev1,

To start, the placeholder attribute does not have very good browser support, 62.24% to be exact. http://caniuse.com/input-placeholder

Secondly, that is the natural functionality of the placeholder attribute, it disappears when you start entering text rather than onfocus.

If you are looking to accomplish a placeholder that is cross-browser, you can use JavaScript (or jQuery) instead.
Code:
<input type="text" name="fname" size="25" placeholder="Username" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Username'" />
All the best,
Sammy12

Last edited by Sammy12; 09-21-2012 at 05:39 AM..
Sammy12 is offline   Reply With Quote
Users who have thanked Sammy12 for this post:
formdev1 (09-21-2012)
Old 09-21-2012, 05:40 AM   PM User | #3
formdev1
New to the CF scene

 
Join Date: Sep 2012
Posts: 5
Thanks: 4
Thanked 0 Times in 0 Posts
formdev1 is an unknown quantity at this point
Ohh Ok. Thanks for your valuable info abt placeholder...
formdev1 is offline   Reply With Quote
Old 09-21-2012, 10:41 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Until recently Firefox did make the placeholder text disappear but they seem to have changed that with the latest major version – obviously a usability decision (if input is focused and placeholder text is hidden you might not know for what the input was, e. g. if you get distracted and return to the form later on).

I must admit that to me it feels like an erroneous implementation but apparently it’s here to stay.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
formdev1 (09-22-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:00 PM.


Advertisement
Log in to turn off these ads.