0
I’m developing a messaging system with initial and final date of each message, so before sending the data via Ajax, I want to validate some fields. I did a good part, the only problem is that when I finish the validation the page is reloaded, preventing the user to perform the correction. Help!
form.ajaxSubmit({
url: 'themes/intranet_fametro/ajax/' + callback + '.ajax.php',
data: {callback_action:callback_action},
dataType: 'json',
beforeSend: function(){
if (callback_action == 'criar-mensagem') {
if(dataInicial < dataAtual){
$("#load").html("Data inicial errada, insira uma data posterior.");
}
else if(dataFinal < dataInicial){
$("#load").html("Data final incorreta, insira uma data posterior.");
}
}
},
success: function(data){
window.location.href = 'mensagem';
}
});
I believe in the
beforeSend
not a good corner to validate.. But if you put onereturn false
within thebeforeSend
I BELIEVE you can for your Ajax that I have not tested. It would not be better to validate before submitting your Ajax ?– Ricardo Lucas
Yes, Validei before sending. Thank you for your attention !
– Moises Abreu