In my ASP.NET MVC 4 application, I am trying to use unobtrusive client validation using Fluent Validation.
<script src="/Scripts/jquery.validate.min.js" type="text/javascript">
</script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript">
</script>
I have two .js files that VS2010 provides when creating a new ASP.NET MVC 4 application. I also included client-side validation in my web.config file.
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
As far as I know, when client validation and unobtrusive JavaScript are enabled, the input fields with the client validation rule contain the data-val = "true" attribute to initiate unobtrusive client validation. And I have this field in my input fields.
For instance,
<input class="input-validation-error" data-val="true" data-val-
required="error text here" id="purchasePrice"
name="PurchasePrice" type="text" value="">
<span class="field-validation-error error" data-valmsg-for="PurchasePrice"
data-valmsg-replace="true">'Purchase Price' must not be empty.</span>
However, when I submit my form, it is sent to the controller, and my model is checked on my control code instead of the client side.
EDIT:
This is my form opening tag.
@using (Html.BeginForm("Create", "Product", FormMethod.Post,
new { enctype = "multipart/form-data", @class = "mainForm",
@id = "productCreateForm" }))
Any ideas? Thank.