//loging validation
$(document).ready(function () {
$('#submit').click(function (event) {
event.preventDefault();
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if (!$('#email').val() || $('#email').val().length === 0) {
swal({
title: "Error!",
text: "Please enter the email..!",
type: 'error',
timer: 2000,
showConfirmButton: false
});
} else if (!emailReg.test($('#email').val())) {
swal({
title: "Error!",
text: "please enter a valid email",
type: 'error',
timer: 2000,
showConfirmButton: false
});
} else {
var formData = new FormData($("form#form-data")[0]);
$.ajax({
url: "post-and-get/ajax/reset-password.php",
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
dataType: "JSON",
success: function (result) {
if (result.status === 'error') {
swal({
title: "Error!",
text: "Invalid email address!...",
type: 'error',
timer: 2000,
showConfirmButton: false
});
} else {
swal({
title: "Success.!",
text: "Password reset email was sent successfully!...",
type: 'success',
timer: 1500,
showConfirmButton: false
}, function () {
setTimeout(function () {
window.location.replace("reset-password.php");
}, 2000);
});
}
}
});
}
return false;
}
);
}); |