the sweet alert does not shoot at me. Maybe it's because of the event. If we comment on the sweet alert and decompose a normal alert if it tells me the message.
In my index, I log in, send data to a servlet, recover the sevlet response and, if your credentials are correct, I send it 1 and redirect to menu, ..., but, because bad credentials.
$(document).ready(function(){
$("#FRM_Login").validate({
rules : {
usuario : {
required : true,
minlength : 5,
maxlength : 25
},
pass : {
required : true,
minlength : 8,
maxlength : 12
}
},
messages : {
usuario : {
required : "El campo usuario es obligatorio",
minlength : "El usuario debe contener al menos 5 caracteres",
maxlength : "El usuario debe contener no mas de 25 caracteres"
},
pass : {
required : "El campo password es obligatorio",
minlength : "La contraseña debe contener al menos 8 caracteres",
maxlength : "La contraseña debe contener no mas de 12 caracteres"
}
},
submitHandler: function (form){
var data = $("#FRM_Login").serialize();
$.post("Login", data, function (respuesta, estado, jqXHR){
if(respuesta === '1'){
$("#BTN_Login").onclick = function(){
swal({
title: "Credenciales Correctas",
text: "Redireccionando...",
type: "success",
timer: 1000,
showConfirmButton: false
});
};
//alert("Credenciales Correctas");
var delay = 2000;
setTimeout(function(){ window.location = "Menu.jsp"; }, delay);
}else{
$(document).ready(function(){
swal("Oops...", "Credenciales Incorrectas!", "error");
};
//alert("Credenciales Incorrectas");
}
$("#usuario").val("");
$("#pass").val("");
});
}
}); });