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 / Checking if numbers an...
Power Apps
Answered

Checking if numbers and letters are in a text input

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

A simple solution I'm sure, but I can't find it anywhere. I have a text input that must contain both numbers and letters in order for the user to proceed. How do I check for this input using an If statement? I know how to do it for numbers or text only, but not both.

 

Thanks for the help in advance!

Categories:
I have the same question (0)
  • Verified answer
    timl Profile Picture
    36,774 Super User 2026 Season 1 on at

    Hi @Anonymous 

    You can do this with a regular expression. Here's the formula you can add to a label.

    If(IsMatch(TextInput1.Text, "([A-Za-z]+[0-9]|[0-9]+[A-Za-z])[A-Za-z0-9]*"),
    "Input OK",
    "Input must contain letters and numbers"
    )
  • Pstork1 Profile Picture
    69,129 Most Valuable Professional on at

    Probably the easiest way would be to use the IsMatch() function and a regex expression.

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-ismatch 

    Try the following for the Regex pattern

    (?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)

    So you could put something like this in the Color property of the text block

    If(IsMatch(TextInput4.Text,"(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)"),Black,Red)

    If the text entry has at least one alpha and one digit then it will be black otherwise it will be red

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you, just what I was looking for.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Also just to add a little, you can shorten your patterns by using the predefined patterns in PowerApps.

    So, this formula would also provide the results and perhaps be a little more readable. 

      IsMatch(TextInput1.Text, MultipleLetters & MultipleDigits)

     

    Happy PowerApp'ing

  • Pstork1 Profile Picture
    69,129 Most Valuable Professional on at

    @RandyHayes  I thought about that one, but won't that require more than one character and digit?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Pstork1 

    Actually, the name is a bit deceiving - even though it is "Multiple" it is defined as "one or more"

    So, "A1" would match, as would "AA11"

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes @Pstork1  thank you both for your help! I will try this also, will be helpful for others deciphering the code in the future. Out of curiosity, does PowerApps have a masked text input option? I have researched this but have found no possible answers. The text input I have requires 3 letters first and then 8 numbers, I was using this check as a plausible workaround. 

     

    Thanks again for your help!

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    No, there is not a masked input control currently.  So, you are limited to validating the control only.

    The Match functions will be the best options for validating the contents.  But, there is nothing that would "force" or "restrict" a user to entering 3 letter and 8 numbers.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Great, thanks for letting me know. A potentially useful idea for the future maybe!

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard