How to clear an input on focus the first time?
html, javascript
Solution
What you want is called a placeholder : a default value that is automatically removed.
If you can accept your placeholder being not visible for IE9- users, do this :
<input type="text" placeholder="username">
If you need to be compatible with IE9, use one of the many polyfills, people have taken care of the implementation details for you.
Problem
I have 2 inputs: ``` <input type="text" value="username"> <input type="password" value="password"> ``` I want to delete the default value (just the first time) if i'm in a specific input. I have add attribute with JavaScript like this: ``` onfocus="this.value='';" ``` But this it clear the input every time focused on it. How to clear the input just the first time focus on it ?