Show a default value in an input field and when you start typing that value is cleared

It sounds to me like what you want to do is use a placeholder. I mean, I don’t really know what the goal is that you want with that default user, but if it’s just guiding the user on what to type in the field, you could do something like this:

By all accounts, from your code, I think it’s a place holder what you wanted to use… but if this is not what you want, then what you need is to use Javascript. First with HTML you indicate a value to the user field:

Then you have to associate a couple of event handlers to the input field. for the “focus” and “blur” events

document.getElementById(‘user’).addEventListener(‘focus’, function() { if(this.value == ‘pepeuser’) { this.value=””; } }); document.getElementById(‘user’).addEventListener(‘blur’, function() { if(this.value == ”) { this.value=”pepeuser”; } });

See also  Submitting a form in PHP reloads the page and displays the PHP code. How to fix it?
Loading Facebook Comments ...
Loading Disqus Comments ...