Skip to content Skip to sidebar Skip to footer

Mvc Form Validation Without Form Submission

I have a standard form populated by an MVC model with standard [Required] validation. I want to 'submit' this form data via AJAX, not by a submit, and I would like to take advantag

Solution 1:

This feature is enabled by default, but it has not been working because you might not have added links to the required JavaScript libraries.

<scriptsrc="~/Scripts/jquery-1.7.1.js"></script><scriptsrc="~/Scripts/jquery.validate.min.js"></script><scriptsrc="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

Solution 2:

Since this is the top answer, when you google for "mvc validation form submit" I have to add another point, which coast me a few hours. When you are using

@Html.ValidationSummary()

in your code, the form get's submited, even if you added these libraries and set

<add key="ClientValidationEnabled"value="true" />
<add key="UnobtrusiveJavaScriptEnabled"value="true" />

in the appSettings property of your webconfig.

Post a Comment for "Mvc Form Validation Without Form Submission"