1
votes

I am trying to get client side validation enabled in Orchard for the comments. I have followed the advice in this SO discussion. I have commented out:

 //ModelValidatorProviders.Providers.Clear();
 //ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider());

I have included the following in Resource Manifest in the Comments Module.

 manifest.DefineScript("jQueryValidation").SetUrl("jquery.validate.js", "jquery.validate.min.js").SetVersion("1.7").SetDependencies("jQuery");
        manifest.DefineScript("jQueryValidation_Unobtrusive").SetUrl("jquery.validate.unobtrusive.js", "jquery.validate.unobtrusive.min.js").SetDependencies("jQuery", "jQueryValidation");

I stuck the following inthe view:

this.Script.Require("jQueryValidation_Unobtrusive").AtHead(); 

Also I added DataAnnotation to the CommentPartRecord.cs file, decorating Author with [Required]

And the changes to the Web.config:

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

And despite all of this server side valdiation for the Comments is whjat works. There is no client side validation.

1

1 Answers

0
votes

The DataAnnotation should'nt be on CommentPartRecord but on CommentPart.

But Orchard.Comments is not a good example because CommentPart doesn't define the same properties than the Record (it will be refactored in a future version).

Try this on another module o one that you create.