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 / TextInput Alphanumeric...
Power Apps
Answered

TextInput Alphanumeric validation

(0) ShareShare
ReportReport
Posted on by 18

Hi Hive Mind,

 

I want to add a validation to a TextInput that disables a submit button if TextInput.Text is not in the range of P00001-P99999.

 

It's probably obvious, but its got me stumped on this Friday morning.  

 

Thanks in advance 👍

Categories:
I have the same question (0)
  • charlessexton Profile Picture
    11 Super User 2024 Season 1 on at

    Here you go:

     

     

     

    If(IsMatch(TextInput1, "^P([0-9]{5})$"), "Matches", "Does not match")

     

     

    Edit: I've just realised this will also match P00000. If that's an issue, we can correct it.

     

    Edit 2: Here you go:

     

    If(IsMatch(TextInput1, "^P(?!0{5})[0-9]{5}$"), "Matches", "Does not match")
  • SieraQuebecLima Profile Picture
    18 on at

    Thanks for the quick reply @charlessexton. Excuse my ignorance, where do I need to apply this?

  • Verified answer
    charlessexton Profile Picture
    11 Super User 2024 Season 1 on at

    Ah, sorry. Put this in the DisplayMode property of your submit button:

     

    If(IsMatch(YOURINPUTCONTROL, "^P(?!0{5})[0-9]{5}$"), DisplayMode.Edit, DisplayMode.Disabled)
  • SieraQuebecLima Profile Picture
    18 on at

    @charlessexton that's awesome, thank you. 

    I do now have an extension question. Can I wrap that in an Or function to achieve validation for the same range of 'H' numbers?

  • Verified answer
    charlessexton Profile Picture
    11 Super User 2024 Season 1 on at

    You could do that, or it can be included in the regular expression in the IsMatch() function, like so:

     

    If(IsMatch(YOURINPUTCONTROL.Text, "^[P|H](?!0{5})[0-9]{5}$"), DisplayMode.Edit, DisplayMode.Disabled)

     

  • SieraQuebecLima Profile Picture
    18 on at

    @charlessexton you've made my Friday awesome. Have a great weekend, and Thank you.

  • charlessexton Profile Picture
    11 Super User 2024 Season 1 on at

    Thanks @SieraQuebecLima . It makes me happy to hear that! Have a great weekend, too. You're very welcome.

  • SieraQuebecLima Profile Picture
    18 on at

    Revisiting this with the aim of offering use of a barcodereader to fill the same textinput. I'd like a scanned input to enable the button also. can this be done?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard