I'm working on a login/register page, in which the forms switch depending on whether the user decide to login or register.
I'm trying to empty all of the <input> when the user switch forms.
I can get to erase all the contents of the <input> fields, but that's including the <input type="submit">, thus also erasing the submit button's message.
Here's what I tried to do to select every input except the submit one, but it doesn't empty the fields anymore :
$('.message a').click(function(){
$('form').animate({height: "toggle", opacity: "toggle"}, "slow");
$(':text, :password, :email').each(function(){
$(this).val('');
});
});
And here's what I tried before, selecting all input, also erasing the "submit" one :
$('.message a').click(function(){
$('form').animate({height: "toggle", opacity: "toggle"}, "slow");
$('input').each(function(){
$(this).val('');
});
});
Also, here's the html :
<div class="form">
<form class="register-form" autocomplete="off">
<input type="text" placeholder="nom" name="name_register"/>
<input type="text" placeholder="prenom" name="last_name_register"/>
<input type="password" placeholder="mot de passe" name="password_register"/>
<input type="email" placeholder="adresse email" name="email_register"/>
<input type="submit" value="Inscription"/>
<p class="message">Already registered? <a href="#" class="register">Sign In</a></p>
</form>
<form class="login-form">
<input type="email" placeholder="adresse email" name="email_login"/>
<input type="password" placeholder="mot de passe" name="password_login"/>
<input type="submit" value="Connexion"/>
<p class="message">Vous n'êtes pas enregistré? <a href="#" class="login">Créer un compte</a></p>
</form>
</div>
inputtag for submit button, usebuttontag instead:<button type="submit">Connexion</button>