Skip to main content
swapnar6405
January 25, 2023
Solved

email validation

  • January 25, 2023
  • 12 replies
  • 0 views

Hi,

I would like to return an error if the user inputs some text instead of email.

I have the below regex and textField.  Can someone guide me how to link these two to perform the required validation.

regexmatch(
  pattern: "^[A-Z0-9\'\+\&\%_-]+(\.{0,1}[A-Z0-9\'\+\&\%_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
  searchString: ri!employee.email,
  regexFlags: "si"
)

a!textField(

label: "Email",

value: ri!employee.email,

saveInto: {ri!employee.email},

inputPurpose: "EMAIL"

)

Best answer by mikes0011

In addition to what Stefan suggested: i would strongly suggest you encapsulate such basic functionality as email address validation into a reusable Expression Rule, rather than hardcoding it onto any interface.

12 replies

stefanhelzle0001
Brainy
January 26, 2023

There is a recipe how to add validations. Check this: docs.appian.com/.../recipe-add-multiple-validation-rules-to-one-component.html

mikes0011
mikes0011Answer
Brainy
January 26, 2023

In addition to what Stefan suggested: i would strongly suggest you encapsulate such basic functionality as email address validation into a reusable Expression Rule, rather than hardcoding it onto any interface.

The Expression Guru
swapnar6405
January 26, 2023

Is there a way, I can link the regex and expression rule and perform email validation.

 

regexmatch(
  pattern: "^[A-Z0-9\'\+\&\%_-]+(\.{0,1}[A-Z0-9\'\+\&\%_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
  searchString: ri!employee.email,
  regexFlags: "si"
)

stefanhelzle0001
Brainy
January 26, 2023

You put that regex into an expression rule and call this in the validations parameter of your text field.