Skip to main content

Notifications

Community site session details

Community site session details

Session Id : S0f3DsfBMNqZdCsxkREk3W
Power Apps - Building Power Apps
Answered

Condition only number to be typed

Like (1) ShareShare
ReportReport
Posted on 2 Aug 2020 13:05:04 by 58

Hi Everyone,

I have textbox were users are allowed to type only numbers. No texts, and special characters allowed so when user types any letter or Special characters I want to show users a notification that only numbers are allowed. To achieve above condition I have created a label with Text "Only numbers are allowed" but I want formula so I cant add the Condition in Visible property of Label to notify the users. Is there a way to achieve this. 

Categories:
  • Verified answer
    v-yutliu-msft Profile Picture
    on 04 Aug 2020 at 05:54:41
    Re: Condition only number to be typed

    Hi @rohitsekar1996 ,

    Do you want to validate whether data in a textinput only has number?

    If so, I suggest you use IsMatch function, which could justify whether data meet the format that you want.

    I've made a similar test for your reference:

    1)insert a textinput for entering data

    2)insert a label to display "Only numbers are allowed" when not meeting requirement

    set the label's Text:

    "Only numbers are allowed"

    set the label's Visible:

    !IsMatch(TextInput1.Text,"[0-9]+")&&!IsBlank(TextInput1.Text)
    //[0-9] means only allows number
    + means zore to more
    

    Then if you enter  texts or special characters, the text will display.

    3)insert a button to submit data.

    Set the submit button's OnSelect:

    If(!IsMatch(TextInput1.Text,"[0-9]+"),
    Notify("Only numbers are allowed",NotificationType.Warning),
    Patch(....)
    )

    //when not meet requirement, you will not submit data and get a notification.

     

     

    Best regards,

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on 02 Aug 2020 at 13:45:41
    Re: Condition only number to be typed

    Hi @rohitsekar1996 

    You could set the Format property of the control to TextFormat.Number and put "This box only accepts numbers" in the hint text. It will accept both integers and decimals. As an alternative, I would recommend the Slider control.  You can set the number limit for Default, Min and Max.  My preference is to give users as few options for entering data as possible, To see more about the slider,

    ref https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-slider 

    For a discussion regarding the TextInput control and limiting it to integers only see https://powerusers.microsoft.com/t5/Building-Power-Apps/Forcing-Integer-input-for-a-Text-Input-Control/td-p/293945 

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,722 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,075 Most Valuable Professional

Leaderboard
Loading started