Define several DataAnnotations for the template which the instance instance.
When the form submission is not for AJAX, everything works as it should, that is, ValidationSummary is populated with ErrorMessage
defined in my classes.
TheproblemiswhenIsubmittheformasynchronouslywithjquery.
Isubmittheform'sSubmitasfollows:
$.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 before even submitting form? In such a way that ValidationSummary
is filled with errors
And yes, I'm validating the model on the Controller as well.