I validate my form with jquery validate and everything goes fine. What won't work is that, after successfully validating I want it to send an alert and clear the form. The alert will pop but the form won't reset. I can make it reset if I don't have the alert, but both won't work at the same time:
$(document).ready(function() {
var validator = $("#contacto").validate({
errorLabelContainer: "#messageBox",
wrapper: "li",
submitHandler: function() { alert("Formulario enviado") }
})
validator.resetForm();
})开发者_运维技巧;
$(document).ready(function() {
var validator = $("#contacto").validate({
errorLabelContainer: "#messageBox",
wrapper: "li",
submitHandler: function() { alert("Formulario enviado");
validator.resetForm();
$("#contacto")[0].reset();
}
})
});
your reset call was outside. so it will be only call once after page load.
Why not:
submitHandler: function( form ) { alert("Formulario enviado"); $(form).reset();
}
?
精彩评论