This is the code from my text box controls, which I added at the end of the OnLoad method:
var fieldInfo = this.FieldInfo;
Label.Text = fieldInfo.Caption;
if (!fieldInfo.AllowEmpty)
{
var errorMessage = fieldInfo.GetPropertyValue(FormFieldPropertyEnum.ValidationErrorMessage);
Label.ShowRequiredMark = true;
rfvTextbox.Text = string.IsNullOrEmpty(errorMessage) ? "This field is required" : errorMessage; ;
rfvTextbox.Enabled = true;
textbox.Attributes.Add("required", string.Empty);
}
else
{
rfvTextbox.Enabled = false;
}
if (fieldInfo.FieldMacroRules.Any())
{
var macroRule = fieldInfo.FieldMacroRules.First();
if (!string.IsNullOrEmpty(fieldInfo.RegularExpression))
{
var actual = Regex.Unescape(fieldInfo.RegularExpression);
textbox.Attributes.Add("pattern", actual);
revTextbox.ValidationExpression = actual;
revTextbox.ErrorMessage = string.IsNullOrEmpty(macroRule.ErrorMessage) ? fieldInfo.GetPropertyValue(FormFieldPropertyEnum.ValidationErrorMessage) : macroRule.ErrorMessage;
}
}
else
{
revTextbox.Enabled = false;
}