Try our conversational search powered by Generative AI!

Episerver forms custom validator never shows in UI

Vote:
 

Hi. 

I am trying to create a custom validator for the latest version of Episerver forms. However, no matter what I do my validator never shows in the UI.  I have tried a few different approached with no luck.

I need to create a regex validator and I have tried the below, which when I tried it a couple of months ago on an older version of Episerver Forms, did show in the UI.

Any help here greatly appreciated.

public class PostCodeValidator : RegularExpressionValidatorBase
{
    public override IValidationModel Model
    {
        get
        {
            if (_model == null)
            {
                string str = "^[1-9][0-9]{3}\s?[a-zA-Z]{2}$";
               _model = GetRegularExpressionValidationModel(str, str);
            }
            return _model;
        }
    }
}
Also, I am aware that I need to add values for this in the language file, but I dont see to have a lang xml at the moment. Does this need to be named anything specific or put in a specific place in the solution?
Thanks
Gary
#173995
Jan 16, 2017 12:56
Vote:
 

instead of 

  if (_model == null)

try empty case or =="" ;

I dont see any problems with your code though, you might need to go to stackoverflow.

____

hdmi modulator

#174516
Jan 28, 2017 12:54
* 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.