$('#login-box').on('hidden.bs.modal', function() { $('#login-form').formValidation('resetForm', true); $("#user_password").val(''); $(".error_msg").text(''); }); $('#pwReset-box').on('hidden.bs.modal', function() { $('#pwReset-form').formValidation('resetForm', true); $("#pwReset_email").val(''); }); $('#LoginButton').click(function(e) { e.preventDefault(); var email = $('#user_email').val(); var password = $('#user_password').val(); var data = $("#login-form").serialize(); if(email != '' && password != '') { $.ajax({ url:"../scripts/login_process.php", method:"POST", data:data, beforeSend: function() { $("#LoginButton").html('   Log In'); }, success:function(data) { if(data == '0') { $(".error_msg").text('The user \''+email+'\' does not exist.'); $("#user_password").val(''); } else if(data == '01') { $(".error_msg").text('Incorrect Username or Password'); $("#user_password").val(''); } else if(data == '02') { $(".error_msg").text('Verification email link not activated'); $("#user_password").val(''); } else if(data == '03') { $(".error_msg").text('The user \''+email+'\' is no longer active.'); $("#user_password").val(''); } else if(data == '1') { $(".error_msg").text(''); $("#LoginButton").html('   Logging In.'); setTimeout('window.location.href = "../myaccount";',1000); } } }); }else{ $(".error_msg").text('Incorrect Username or Password'); $("#user_password").val(''); } }); $('#pwReset').click(function(e) { e.preventDefault(); $('#login-box').hide(); $('.modal-backdrop').remove(); $('#pwReset-box').modal({show: true, backdrop: 'static', keyboard: false}); }); $('#CloseButton').click(function(e) { e.preventDefault(); $('#pwReset-box').hide(); $('.modal-backdrop').remove(); location.reload(); }); $('#LoginReset').click(function(e) { e.preventDefault(); var email = $('#pwReset_email').val(); var data = $("#pwReset-form").serialize(); if(email != '') { $.ajax({ url:"../scripts/pw_reset.php", method:"POST", data:data, beforeSend: function() { $("#LoginReset").html('   Resetting Password'); setTimeout('',1000); }, success:function(data) { if(data == '0') { $("#LoginReset").html('   Reset password'); $(".pwerror_msg").text('Invalid Username'); $("#pwReset_email").val(''); } else if(data == '01') { $("#LoginReset").html('   Reset password'); $(".pwerror_msg").text('The user \''+email+'\' is no longer active.'); $("#pwReset_email").val(''); } else if(data == '1') { $(".pwerror_msg").text('Password Reset link has been sent to your email.'); $('#pwReset-form').hide(); $('#CloseX').addClass('hidden'); $('#CloseButton').removeClass('hidden').removeAttr('disabled'); } } }); }else{ $(".pwerror_msg").text('Invalid Username'); } });