Hi there!
I am struggling with a basic email validation if statement and was wondering if someone could help. I have a text input in a power app that requires a user to put in an email address. The conditions required for the email address is either that it is matches the same format of a RegEx statement I have or the text box is blank. Below is the statement:
If(!IsMatch(personalEmaiInput.Text, "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$") || !IsBlank(personalEmaiInput.Text), Set(varValidEmail, true), Set(varValidEmail, false))
This condition would control the Visible property of the error message. I want it to show the error message only if the email is invalid. This condition is on the OnChange property of the text input. When the conditions are met, it's meant to show an error text message and it should disappear when you enter a valid email address. The problem I am having is that it's showing the error message whether or not the email is valid.
The testing for this I have done is the following:
- many variations of checking if the text input is blank which include
- checking if personalEmailInput.Text <> Blank()
- checking if personalEmailInput.Text <> ""
- Instead of using "||", I tried using only one condition at a time and they work individually as expected
- the error message disappears when it meets the conditions
Any help or guidance would be appreciated! Please let me know if you need anymore information or screenshots etc.