Skip to main content
August 23, 2024
Question

Is it possible to validate that an input is of type email?

  • August 23, 2024
  • 10 replies
  • 1 view

Is it possible to validate that an input is of type email, so that if the user enters something that is not an email, a warning can be showed?

10 replies

venkatrea696188
August 23, 2024

 Usually for validating email we use Regex code , it is going to check the format of the entered email text . Not sure what you are looking for , can you give more details of your usecase?

luciamAuthor
August 23, 2024

and how do u use a regex code in an input?

konduruc733182
August 23, 2024

[mention:6b905e9a23224b10ad37b79eb1eea628:e9ed411860ed4f2ba0265705b8793d05]  Replace the value in the "^[a-z0-9]+(\.[a-z0-9]+)*@[a-z0-9]+(\.[a-z0-9]+)*(\.[a-z]{2,5})$" with a constant.

if(
  a!isNullOrEmpty(ri!input),
  null,
  if(
    regexmatch(
      "^[a-z0-9]+(\.[a-z0-9]+)*@[a-z0-9]+(\.[a-z0-9]+)*(\.[a-z]{2,5})$",
      ri!input
    ),
    "",
    "Please enter a valid email address"
  )
)

mikes0011
Brainy
August 23, 2024

If you mean you want to validate that a particular string is a valid email address, the People Funcitons plug-in currently has a function, validateemailaddress(), which validates email addresses as well as any Regex pattern or OOB appian expression can do (and i know because i've written both in the past from scratch).

If you go with the RegEx approach as other commentors have suggested here, the best pattern I've found so far which accepts the largest range of valid email addresses, is as follows (this is the actual expression rule I currently use):

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

Note, the "validateEmailAddress()" function in People Functions currently passes the same extensive list of test cases as the above expression rule, and is a little easier to use routinely.

luciamAuthor
September 3, 2024

thanks [emoticon:c4563cd7d5574777a71c318021cbbcc8]♥

mathieud0001
September 5, 2024

Another option that I don't see being discussed much is using a real time email validation API if you require more in depth verification.