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 / Regular Expression for...
Power Apps
Unanswered

Regular Expression for Textbox

(0) ShareShare
ReportReport
Posted on by 50

Hi, 

 

I have a textbox which should take "*" as default value. Also, it should accept only numeric values up to 1 decimal point and value should not be greater than 100, since it is percentage.

 

Example: Accepted values in Textbox : *, 23.1, 32.1, 100, etc..

Not Accepted : 23.22, 101, etc..

 

Please help me with regular expression or what is the best way to achieve this.

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @vakula 

    Can you describe your scenario a bit more?  Are you stating that you want the TextInput to validate as the user types something and only allow certain patterns?  If so, then this is Input Masking that PowerApps does not currently support. 

    If you are trying to achieve some sort of visual notification (red border, a warning message, etc.) then this can be achieved and can be best done with a series of verifications including, but not limited to, a regular expression.

  • CU-18081211-6 Profile Picture
    9,270 Moderator on at

    Hi @vakula ,

    Starting from the second assumption of @RandyHayes here is a proposal:

    IsMatch(TextInput.Text,"\d\d.\d") || Value(TextInput.Text)=100 || TextInput.Text="*"

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

    @gabibalaban 

    Actually, that expression will not match the conditions properly.  That formula would assume that all inputs have to have a decimal and digit.

    It would go more like this:

       With({val: TextInput.Text,}, IsMatch(val, "\d{2}(\.\d)?") || val="100" || val="*")

     

    The above regex allows for two digits and an optional decimal and digit.  Three digit numbers would only be 100 and is tested for outside of the regex.

  • Vakula Profile Picture
    50 on at

    @RandyHayesShould this be written on Onchange Property of textbox?

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @vakula 

    No, it will do nothing there.  As mentioned - "If you are trying to achieve some sort of visual notification (red border, a warning message, etc.) then this ..."

    So, for example, this formula on the Fill property of the TextInput will give you visual indication of the error.

     

        If(With({val: Self.Text,}, IsMatch(val, "\d{2}(\.\d)?") || val="100" || val="*"), Transparent, Red)

     

     

  • Vakula Profile Picture
    50 on at

    @RandyHayes Thanks, It worked!!

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard