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 / How to make a range of...
Power Apps
Answered

How to make a range of numbers in a text input

(0) ShareShare
ReportReport
Posted on by 364

Hi all, 

 

I am currently working on an app that tracks the hours spent on engineering projects. I am wondering how I could set a text input to prevent the end users from entering a number above or below a certain range. For example, they shouldn't be allowed to enter a number below 0 or above 12. The number will later be submitted and updated to a column storing numerical values. 

 

Thank you for any feedback!

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

    Hi @Aurora 

     

    1. Set Onchange property of text control to

    If(
     Value(txtHoursWorked.Text) <= 0 || Value(txtHoursWorked.Text) > 12,
     Reset(txtHoursWorked)
    )

     

    2. Insert Label control to display message. Set Visible property of the label to

    IsBlank(txtHoursWorked.Text) || Value(txtHoursWorked.Text) <= 0 || Value(txtHoursWorked.Text) > 12

     

    3. Set Text property of Label to

    "Your typed value should not greater than the 12 or less than 0"

     

    Sample

    StalinPonnusamy_0-1631728809888.png

     

     

  • Akshay_R-MCT Profile Picture
    15 on at

    Hi @Aurora 

     

    I believe this will restrict user entering data above 12 hours

     

    Akshay_RMCT_0-1631719726447.png

    Add below code in Onchange of Text Box

    If(
    Value(txtHoursWorked.Text) <= 0 Or Value(txtHoursWorked.Text) > 12, Notify("Your typed value should not greater than the 12 or less than 0",NotificationType.Error)
    )

     

  • Aurora Profile Picture
    364 on at

    @StalinPonnusamy 

    I suppose that would be one way to do it. In my head I was envisioning a text input that prevents the users from even entering a number outside of the range, the engineers should know the limit on hours they can submit at a time. So if one enters a "13" on accident instead of a "12" then I was hoping the text input could refuse to let a number over 12 even be entered. 

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Aurora

     

    I believe our goal is to verify the text input whether the user entered validly or not. The user should be able to save the form is only valid. So

    On click on submit button or Save button 

     

    If(Value(TextInput10.Text) <= 12 && Value(TextInput10.Text) > 0), SubmitForm(FromName), Notify("Not valid input"))

     

    Let me know are were talking about different things.

  • Aurora Profile Picture
    364 on at

    @Akshay_R-MCT if I try to put If(Value(txtHoursWorked.Text) <= 0 And Value(txtHoursWorked.Text) >12, true, false) in the visible field the text input disappears, i have it in clear with no errors but it still isn't fully working.

  • Akshay_R-MCT Profile Picture
    15 on at

    Hi @Aurora 

     

    Drop and drag Text box in screen, there you find clear

     

    Akshay_RMCT_0-1631713589649.png

     

  • Aurora Profile Picture
    364 on at

    I also can't seem to find either OnClear or OnVisible for the text input. 

    Capture.PNG

  • Aurora Profile Picture
    364 on at

    I don't see "text" as an option for this text input, I would prefer to not use a dropdown here if possible. 

    Capture.PNG
  • Akshay_R-MCT Profile Picture
    15 on at

    Hi @Aurora 

     

    I tried this from my side, its working perfectly fine for me.

    This may help for you.

     

    1) Add on Textbox, in OnClear add this code :

       If (Value(Inputbox.Text) <= 0 and Value(InputBox.Text) > 12, true, false)

    2) Add on label below and show popup when they enter less than 0 and more than 12.

       If (Value(Inputbox.Text) <= 0 and Value(InputBox.Text) > 12, true, false) add this code on label onvisible.

       

    If this solve your issue please mark as solved.

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Aurora 

     

    Option 1: We can use Dropdown since we know the valid values

    StalinPonnusamy_0-1631711587511.png

     

    Option 2: Validate the entry Value(TextInput10.Text) <= 12 

     

    StalinPonnusamy_1-1631711635622.png

     

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
Kalathiya Profile Picture

Kalathiya 428

#2
WarrenBelz Profile Picture

WarrenBelz 374 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 333 Super User 2025 Season 2

Last 30 days Overall leaderboard