Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    5
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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....

  • #2
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    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.

  • Users who have thanked Sammy12 for this post:

    formdev1 (09-21-2012)

  • #3
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    5
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Ohh Ok. Thanks for your valuable info abt placeholder...

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,607
    Thanks
    6
    Thanked 997 Times in 970 Posts
    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.

  • Users who have thanked VIPStephan for this post:

    formdev1 (09-22-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •