Home > DeveloperSection > Forums > Is it possible to change input value using CSS?
john rob

Total Post:108

Points:756
Posted on    March-05-2013 2:50 AM

 CSS-CSS3 CSS-CSS3 
Ratings:


 1 Reply(s)
 1181  View(s)
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!



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    March-05-2013 8:04 AM

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" />


Don't want to miss updates? Please click the below button!

Follow MindStick