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"
)
Discussion posts and replies are publicly visible
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.
Is there a way, I can link the regex and expression rule and perform email validation.
You put that regex into an expression rule and call this in the validations parameter of your text field.
I don't have Regular Expression Plug-in, so not sure if I can use the pattern which I am talking.
Then install that plugin from the admin console.
You can also do a more simple check. E.g. just check for the existence of a @ and a dot. This would not require any plugin.
Not only @ , dot. I have to check at least few characters between @ and dot and few characters before @.
That would be a very simplified check.
a!forEach( items: { "this.is.my.email@example.com", "invalid.org", "missing.top.level@appian" }, expression: like( fv!item, "*@*.*" ) )
swapnar6405 said:I don't have Regular Expression Plug-in
It takes about 5 seconds to install. Is there any reason you can't?
Additionally the People Functions plug-in has a built-in function now, "validateEmailAddress()", which works at least as well as the Regex version you posted here originally (which looks like the one i've posted in the past elsewhere).
Both People Functions and the RegEx plugin should be considered standard and non-controversial, so I'm unclear why you would want to / be required to avoid using them. Can you provide any more info on this?
If push comes to shove, the old thread I linked above contains my "classic" OOB rule that does a pretty good job at validating an email address, but I personally recommend just using the RegEx or People Functions versions now, unless in an emergency.
I have modified little bit, not it is working as per my requirement. Thank you so much for your help.
a!forEach( items: { "email@example.com", "invalid.org", "missing.top.level@appian", "swapna@.", "swapna@a.c" }, expression: like( fv!item, "?*@?*.?*" ) )
Like Mike I still strongly recommend using the regex or the people functions plugin.