IS IT POSSIBLE TO CHANGE INPUT VALUE USING CSS?

john rob

Total Post:108

Points:756
Posted by  john rob
 1586  View(s)
Ratings:
Rate this:

Hi Expert!

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

Like:

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

Thanks!

  1. AVADHESH PATEL

    Post:604

    Points:4228
    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" />

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!