I have created a login and a registration forms inside a modal. you can switch over the two forms just by clicking either on the heading(h2)
or on the switcher(span)
.
Till now every thing is working perfect however when i click several times 8 or 10 on the switchers ('heading or span') both forms appears !!! here is the code
$('#modal-switcher, #modalheading').on('click', function(){
// reset form on switch
$('.modal-content form').trigger('reset');
var h2 = $('#modalheading'),
signup = $('#modalsignupform'),
login = $('#modalloginform'),
switcher = $('#modal-switcher');
if(h2.hasClass('signup')){
h2.addClass('login').removeClass('signup').html('Login OR <a id="modal-switcher1">Signup</a>');
signup.hide();
login.fadeIn('slow');
switcher.text('Go to signup');
}else{
h2.addClass('signup').removeClass('login').html('Signup OR <a id="modal-switcher1">Login</a>');
login.hide();
signup.fadeIn('slow');
switcher.text('Go to login');
}
});
any explanation why several clicks cause this problem ??? what could be a good solution for thanks !!