I've got a simple Jquery Ajax request working that logs in a user and returns a simple "Success" or "Failure" text back to the current page in a specific div.
I would like, however, to make it so that if the user has succesfully logged in - then the pop-up window would close but if they did not pass the JS validation or the PHP validation, then they would stay in the pop-up window and the errors would be shown.
Current Jquery code:
$(document).ready(function(){
$("#myform").validate({
debug: false,
rules: {
pass: "required",
user: {
required: true,
email: true
}
},
messages: {
pass: "Please provide your password.",
user: "Not a valid email addesss to log you in.",
},
submitHandler: function(form) {
$.post('/register/process.php', $("#myform").serialize(), function(data) {
$('#results').html(data);
});
}
});
});
Have tried using the window.close(); but that obviously closes the window no matter what the result of the login is.
*Any way to check if it has actually succeeded or if if the user input is not correct?
Thanks!
-Tec