This class allows customizable errors to be displayed for each component when an error occurs. It has the following properties:

  • required
  • min
  • max
  • minLength
  • maxLength
  • invalid_email
  • invalid_date
  • pattern
  • custom

The values of these properties are the messages you wish to display once an error of that type occurs. Within the message, you can use {{ field }} to include the component's label. The following example shows a custom error message shown when a required component was left empty:

The initialization code is as follows:

txt         = component.TextField("name_field", form);
txt.label   = "Name";

customError             = componentProperties.Error(txt);
customError.required    = "Field {{ field }} is required. Please try again.";

btn         = component.Button("submit", form);
btn.label   = "Submit";
txt = component.TextField("name_field", form)
txt.label = "Name"

customError = componentProperties.Error(txt)
customError.required = "Field {{ field }} is required. Please try again."

btn = component.Button("submit", form)
btn.label = "Submit"