I have set an OnSubmit()
property to @Html.BeginForm()
that calls this function:
$('form').submit(function () {
deleteImages();
return true;
});
The problem is, this gets executed even if the form isn’t valid. How do I check if the form is valid, then call the function?
2
Answers
You can try ubobtrusive validation (if you are using Jquery)
This might help.
I don’t know the logic in your application, but if you are afraid of someone messing with you JS, then you should do validation on the server as well (Its always better to have validation on both – client and server side)! Validate it on the server and return a flag or something, then you will know that you have to execute deleteImages()