23

How to show a default value in apex:inputText so that when user enters the text box the value should disappear like it does in this HTML:

<input type="{!username}"  id="username" placeholder="Username"/>
<input type="{!password}"  id="password" placeholder="Password" /> 

Can anyone please suggest how to implement this in Visualforce?

  • How can we change the color of placeholder text – user42978 Mar 15 '17 at 19:22
43

You can use the recently introduced pass through attributes for this:

<apex:inputText value="{!username}" id="username" html-placeholder="Username"/>
<apex:inputSecret value="{!password}" id="password" html-placeholder="Password"/>

PS Cool page that lets you know Can I use input placeholder attribute?

  • 2
    I always forget about this feature. Great answer – Chris Duncombe Nov 8 '13 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.