web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Email validation in te...
Power Apps
Answered

Email validation in text input

(0) ShareShare
ReportReport
Posted on by 90

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.

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @jojos_iq ,

     

    Please try this

    If(IsMatch(TextInput1.Text, "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$"), Set(varValidEmail, true), Set(varValidEmail, false))

     

    Best Regards,

    Wearsky

  • swaminawale Profile Picture
    195 on at

    Hi @jojos_iq ,

     

    Instead of onchange, you can put the formula on "Visibile" property of error message label

     

    !IsBlank(personalEmaiInput.Text) && If(
     IsMatch(personalEmaiInput.Text, "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$"),
     false,
     true
    )

     

    Let me know if this works and if yes, then please accept it as a solution. 

    Thanks 🙂 

  • jojos_iq Profile Picture
    90 on at

    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!

  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    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

  • swaminawale Profile Picture
    195 on at

    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

  • jojos_iq Profile Picture
    90 on at

    Your solution worked @v-xiaochen-msft - cheers mate!

  • P_Anica Profile Picture
    23 on at

    Hi,

    The following regular expression is a better: 

    IsMatch(tbEmail.Text, "^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$")
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    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)

     

  • jojos_iq Profile Picture
    90 on at

    Weird plug but aight

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Added that cos the IsMatch being used doesn't actually catch all valid emails 🤷

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 103

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
wolenberg_ Profile Picture

wolenberg_ 67 Super User 2026 Season 1

Last 30 days Overall leaderboard