Is it possible to change input value using CSS?

Total Post:108


 2041  View(s)
Rate this:

Hi Expert!

Can I change an input field value using CSS when user clicks it?


<input type=text name=username>
<input type=password name=password>

So, when the user click into this field, the text will go away and he will be able to write something.


  1. Re: Is it possible to change input value using CSS?

    Hi John!

    If you change input value then you can do as below, there is no role of css

    <input type="text" name="username" placeholder="Username" />

    Because "placeholder" attribute not suported by all browser, then you can achive this using JavaScript.

    <input type="text" name="username" onFocus="if(this.value=='Username') this.value='';" onBlur="if(this.value=='') this.value='Username';" value="Username" />


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.