This project is read-only.

Client validation on custom form not working

Topics: General, Writing modules
Dec 5, 2013 at 11:16 PM
Edited Dec 5, 2013 at 11:18 PM

I've tried implementing client-side validation on a custom form in Orchard without success, and was hoping someone could help me identify what the problem is. For now I'm using server side validation, but I would prefer client-side validation to avoid unnecessary post backs.

Here is the way things are setup. I'm running Orchard 1.7 on VS 2013.
  • I have a model with validation attributes defined, and this model is binded to my view.
  • The following scripts are defined in my view, and exist in the module's scripts folder
  • the module's script folder web.config allows static files to be returned
    <add name="StaticFile" path="" verb="" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
  • I have the ValidationSummary method called after the form declaration:
    @using (Html.BeginForm())
  • Orchard's web root web.config have the following settings enabled
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />

However when I hit submit, the form never validates client side. Even if I leave some mandatory fields blank, the form posts anyways, and I'm stuck validating the form in my controller. When the view reloads, the validation summary then shows the appropriate error messages.

Would someome have an idea on what might be causing the client side validation to be failing?

Thanks for your help!
Dec 6, 2013 at 4:18 PM
Edited Dec 6, 2013 at 4:23 PM
Hi JasperD, thanks for your help but I should have specified I'm running build 1.7.2, I already have the fix you mentioned, yet client validation is still not working..