Adding a Validation Pattern
Customize the regular expression based validation patterns available for text fields.
Provided patterns
Creating a custom validation pattern
using Umbraco.Forms.Core.Interfaces;
namespace Umbraco.Forms.TestSite.Business.ValidationPatterns
{
public class UkPostCode : IValidationPattern
{
public string Alias => "ukPostCode";
public string Name => "UK Post Code";
public string LabelKey => string.Empty;
public string Pattern => @"^([a-zA-Z]{1,2}[a-zA-Z\d]{1,2})\s(\d[a-zA-Z]{2})$";
public bool ReadOnly => true;
}
}Registering the validation pattern
Using the pattern

PreviousAdding A Server-Side Notification Handler To Umbraco FormsNextCustomize Default Fields and Workflows For a Form
Last updated
Was this helpful?