I have the following, which doesn’t work, my validation seems that it’s not triggered on the form submit.
<script src="/Public/javascript/jquery-ui-1.8.13.min.js" type="text/javascript"></script>
<script src="/Public/javascript/jquery.unobtrusive-ajax.js" type="text/javascript"></script>
<script src="/Public/javascript/jquery.validate.min.js" type="text/javascript"></script>
......
<form action="/Controller/Action" data-ajax="true" data-ajax-complete="bla();" data-ajax-method="POST" id="MyAjaxForm" method="post">
.........
<input data-val="true" data-val-required="The x field is required." id="ViewModel_x" name="ViewModel.x" type="text" value="">
<span class="field-validation-valid" data-valmsg-for="ViewModel.x" data-valmsg-replace="true"></span>
.........
<a href="#" id="saveButton" onclick="$('#MyAjaxForm').submit();">Some button text</a>
</form>
Do you see something wrong in the generated markup?
Thanks in advance.
Yes, you seem to have forgotten to include the
jquery.validate.unobtrusive.jsscript which is what interprets the HTML5data-*validation attributes on your input fields and emitsjquery.validaterules: