I'm facing a strange issue since morning.
I have a Model
, Controller
and corresponding strongly typed View
for ASP.NET MVC 4
In the view I'm using jquery, juqery.validate
and jquery.unobtrusive.validate
as follows:-
<script src="../../Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.form.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>
Now, if Jquery Unobtrusive Validate script files are imported, the form submitEvent
will not get caught but skips it & submits the form -- means, the below code is skipped if I use jquery.validate.min.js
and jquery.validate.unobtrusive.min.js
$(document).ready(function () {
$('form').submit(function (e) {
alert('Submitting');
e.preventDefault();
});
});
And, If I remove jquery.validate.min.js
and jquery.validate.unobtrusive.min.js
script files the above form submit event
gets caught.
Ultimatey I want to use Unobtrusive Jquery Validation for my MVC Model/View as well as ajax Post method
preventing normal submit, say by doing event.PreventDefault();
on submission
Kindly help, and Thank you all :-)