I have a login form which contains a username field, password field, and a submit button like so:
<form id="myform" name="myform" method="post" action="servlet/url">
<label>Username:</label>
<input type="text" name="username" value="user_name" placeholder="Username">
<label>Password:</label>
<input type="text" name="user_pwd" value="" placeholder="Password" onfocus="javascript:this.value=''">
<input type="submit" value="Submit">
</form>
If I click the submit button, it works as expected. However, pressing the enter key clears the password value UNLESS I click out of the password field first. I know that this is because of my onfocus attribute, however I would still like the password field to clear away automatically if you click back into it. What could be the cause of the enter key clearing the field?