You can use the placeholder because it does it for you, but for older browsers that do not support the placeholder, try the following:
<script> function clearThis(target) { if (target.value == " exemplo@exemplo.com ") { target.value = ""; } } function replace(target) { if (target.value == "" || target.value == null) { target.value == " exemplo@exemplo.com "; } } </script> <input type="text" name="email" value=" exemplo@exemplo.com " size="x" onfocus="clearThis(this)" onblur="replace(this)" />
EXPLANATION: When the text field has focus, clear the value. When the text field is not focused, and when the field is empty, replace the value.
I hope this works, I had the same problem, but then I tried it and it worked for me.
source share