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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Validate Emails (Text ...
Power Apps
Unanswered

Validate Emails (Text Input) Separated by Semicolon to Match Several Domains?

(0) ShareShare
ReportReport
Posted on by

I have a text input for email addresses and the user can provide a single email or multiple emails separated by a semicolon.  I need to validate the email(s) to match 1 of 2 domains (abc.com or def.com).  My issue is that the code below works great, but how do I accomplish this validation for multiple emails separated by a semicolon?

// WORKS - Validate email text input as 1) Valid email, 2) Whitelist ABC & DEF domains 
If(IsMatch(TextInput1.Text, 
 "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$"
 ) And
 Last(Split(TextInput1.Text, "@")).Result 
 in ["abc.com", "def.com"]
 ,
 Notify("Email IS valid", NotificationType.Success),
 Notify("Email not valid", NotificationType.Error)
)

 

Categories:
I have the same question (0)
  • Verified answer
    sgtsnacks Profile Picture
    62 on at

    You can use Split(string,delimiter) combined with a ForAll() to achieve this. You can also use the result to add to your notification to identify the address in question.

     

    Clear(mailtest);ForAll(Split(txt_Mails.Text,";").Result,
     If(IsMatch(ThisRecord.Result, 
     "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$"
     ) And
     Last(Split(ThisRecord.Result, "@")).Result 
     in ["abc.com", "def.com"]
     ,
     Collect(mailtest,ThisRecord.Result & " is Valid");Notify(Last(mailtest.Value).Value,NotificationType.Success),
     Collect(mailtest,ThisRecord.Result & " is Not Valid");Notify(Last(mailtest.Value).Value,NotificationType.Error))
    )

     

    I've added a collection (mailtest) statement above to capture the results and display them in a ListBox, for demonstration purposes. This may not be required in production.

     

    sgtsnacks_0-1637085777654.png

    sgtsnacks_1-1637085815405.png

     

  • Community Power Platform Member Profile Picture
    on at

    @sgtsnacks - This worked - thank you!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard