In Sitecore 10 forms, I am trying a very simple regex


This regular expression matches strings that either start with a plus sign followed by at least 9 digits or consist of at least 10 digits alone. The plus sign at the start is optional, and the overall minimum length is 10 characters

This is not even showing in the front-end. The attribute **data-val-regex-pattern is missing.

I tried this regex {"regularExpression":"^[0-9]*$"} which is working and also showing the attribute data-val-regex-pattern="^[0-9]*$" but not the regex with option to have '+' sign in the start.

Is there anything I am doing wrong?

1 Answer 1


We faced similar issue after creating a new field validator. Surprisingly, RegularExpressionValidation could not evaluate this.Parameters?.RegularExpression So we created a custom regex validator,

//Sitecore namespace - Sitecore.ExperienceForms.Mvc.Models.Validation
public class CustomRegularExpressionValidation : ValidationElement<RegularExpressionParameters>
public override void Initialize(object validationModel)
      if (validationModel is StringInputViewModel stringInputViewModel)
        this.Title = stringInputViewModel.Title;
      // This was not evaluating as expected      
      //this.RegularExpression = this.Parameters?.RegularExpression ?? string.Empty;
      // so added this
      this.RegularExpression = this.ValidationItem.Parameters ?? string.Empty; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.