I have a form and want to switch between the login and register easily. I have it set so that if the user clicks register the register form shows and that button changes to a button that will take them back to the login form if desired.
However when the user goes back to the login form, it won't let them get back to the register form again.
$('.register-form').hide();
$('a.register').click(function() {
$('.login-form').hide();
$('.register-form').show();
$('button').text('Register');
$('a.register').removeClass('register').addClass('login-return').text('Back to Login');
});
$('a.login-return').click(function() {
$('.register-form').hide();
$('.login-form').show();
$('button').text('Login');
$('a.login-return').removeClass('login-return').addClass('register').text('Register');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<div class="login-form">
<input type="email" name="email" placeholder="email"><br/>
<input type="password" name="password" placeholder="password">
</div>
<div class="register-form">
<input type="text" name="register-name" placeholder="name"><br/>
<input type="email" name="register-email" placeholder="email"><br/>
<input type="password" name="register-password" placeholder="password">
</div>
<button type="submit">Login</button>
<a href="#" class="register">Register</a>
</form>