Try our conversational search powered by Generative AI!

EPiServer Forms custom validator

Vote:
 

I'm trying to implement a custom validator for my form elements. I started following this post By Mark van Dijk. There it says that in order to get the javascript to load correctly, the following lines of code needs to be implemented:

[ServiceConfiguration(ServiceType = typeof(IViewModeExternalResources))]
public class FormsViewModeExternalResource : IViewModeExternalResources
{
public IEnumerable> Resources
{
get
{
var arrRes = new List>
{
new Tuple("script", 
"/ClientResources/ViewMode/FormsValidators.js"),
};
return arrRes;
}
}
}



Correct me if I'm wrong, but as what I can see, the file FormsValidators.js have been removed in 3.0.0 and "baked into" EPiServerForms.js? Then when I substitute the line above with the following:

/ClientResources/ViewMode/EPiServerForms.js



I end up with a 404.

Should I be using a different approach here or what?

Thanks in advance

/ Carl

#151511
Jul 26, 2016 15:39
Vote:
 

Hi  Carl

I can't remember such file FormsValidators.js. We don't have that.

I have provided fully working example (and production level) code at https://github.com/episerver/EPiServer.Forms.Samples

You can take a look at DateTimeValidator and RecapchaValidator

Hope this help.

Thach Lockevn.

#151618
Aug 01, 2016 6:37
Vote:
 

hi Thach

How can we enable server side validation on for example textbox ? we get spam in forms, even when text field has client side email validation On.

regards

Nitin

#211337
Jan 03, 2020 11:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.