[jQuery] Control form submitting
<div dir="ltr">Hi all, is there some way how to control form submittin within succes or error calback functions within beforeSubmit callback function?
In my my code I validate form data at client side, when form is valid I send data to server by callback function beforeSubmit.
Server does another validation and return response. By this response I need to decide whether to submit or do not submit. But then (I guess) I cannot control return value by beforeSubmit function.
$(document).ready(function() {
var v = jQuery("#registration").validate({
submitHandler: function(form) {
jQuery(form).ajaxSubmit({
url: '/registration/form/',
success: function(response) {
// user has been registered
},
beforeSubmit: function(formData) {
$.ajax({
type: "POST",
url: "/registration/check/",
data: formData,
processData: true,
success: function(response){
// process response
},
error: function(){
// some error occured
}
});
}
});
}
});
});
</div>