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:
Any help or guidance would be appreciated! Please let me know if you need anymore information or screenshots etc.
😂
No worries, glad it was useful!
Just messing with you, it was actually a good value link - thanks for that, brother!
Added that cos the IsMatch being used doesn't actually catch all valid emails 🤷
Weird plug but aight
Hey I know this is already solved, just going to add here that I have a blog post that covers a regex formula that uses the RFC5322 standard to include all possible allowed characters under that convention
Email validation in Power Apps - iAm_ManCat Blog (iammancat.dev)
Hi,
The following regular expression is a better:
IsMatch(tbEmail.Text, "^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$") |
I did a modification in your code:
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 should work now
Hi @jojos_iq ,
Please try this
If(IsMatch(personalEmaiInput.Text, "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$") || IsBlank(personalEmaiInput.Text), Set(varValidEmail, false), Set(varValidEmail, true))
Best Regards,
Wearsky
Hi @v-xiaochen-msft
This one would set the variable to true if it matches, but the variable is used to determine the Visible property of the error message. I don't want it to appear if it matches. I will adjust my problem now in the main post!
Thank you!
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional