0
I defined several Dataannotations for the model which the instancia form.
When the Form Ubmit is not by AJAX everything works as it should, ie the Validationsummary is filled with the ErrorMessage
defined in my classes.
The problem is when I perform the form Submit asynchronously with jquery.
Submit the form as follows:
$.ajax({
url: '@Url.Action("CriarEvento")',
type: 'POST',
data: $(this).serialize() + '?preco=' + preco,
success: function (obj) {
if (obj.success == true) {
alert('evento salvo com sucesso');
$('#fecharCrEvento').click();
$('#calendario').fullCalendar('refetchEvents');
}
else {
}
}
}).
How can I use the same validation defined in Dataannotations even before form Submit? Such that the ValidationSummary
is filled in with errors
And yes, I’m validating the model in Controller as well.
As soon as I get home I’ll be in the code and I’ll let you know! (:
– Fernando Medeiros
But in case it only checks whether it is valid or already displays the errors
– Fernando Medeiros
He does both, checks and displays errors.
– João Alex