I am using an Ajax.BeginForm with unobtrusive validation. I want to give the user the option to save the data with a minimum number of validated fields (which might be zero) but allow some required fields to be saved when empty.
I think my requirements are:
- add an event handler to the submit button
- perform the validation manually
- identify which fields have failed validation because they are empty
- identify which fields have failed validation the data is in error
I can catch the submit event and validate the form by adding the following at "document ready"
$(document).ready(function () {
$('#submit-11').click(function () {
if (!$("#form0").valid()) {
alert("woops");
return false;
}
return true;
});
My problem now is how to identify which fields have failed validation and the reason for failing.
I can find nothing on Google (although that may be a function of my search skills rather than the problem.)
Thanks in advance.