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 / How to only allow inpu...
Power Apps
Answered

How to only allow input of 1 through 9 in a text box?

(0) ShareShare
ReportReport
Posted on by 359

hi. i have a data field text box. i don't want anyone to put in any value outside of 1 through 9.

 

how do i do this?

Categories:
I have the same question (0)
  • PowerBack19 Profile Picture
    679 on at

    Is this in a Canvas App or Model-Driven App?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    You could use the slider control instead. It has Max and min properties.

    However, for a textbox, you could set the OnChange property of the textbox to this:

     

    If(
     Value(TextInput1.Text) > 9 || Value(TextInput1.Text) < 1,
     Notify(
     "Invalid entry. Please enter a number 1 through 9",
     NotificationType.Error
     ) && Reset(TextInput1)
    )

     

    Where TextInput1 is the textbox you're using. 

  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @cchan000 ,

    Which one do you mean?

    1) user could only enter 1-9 ?

    2)user could only enter text that only has 1-9 number?

    When user enter invalid text, what action do you want? display a warning or just can not enter into the textinput?

     

    A. how to justify

    1)if you want to user could only enter 1-9,please use this to justify:

    Value(TextInput1.Text)>=1&&Value(TextInput1.Text)<=9

    2)if you want to user could only enter text that only has 1-9 number,please use this to justify:

    IsNumeric(TextInput1.Text)&&!(0 in TextInput1.Text)

    B.action

    (set the textinput's OnChange)

    1)if you want to show warning, please try this:

    If(formula1=false,Notify("you've entered invalid word",NotificationType.Warning))

     //formula1 is the justify formulas that I listed above, please choose one to replace it.

    2)if you want to user can not enter invalid text into the textinput,please try this:

    set Textinput's Default: var1

    set textinput's format to number

    12304.PNG

     

    user could only enter 1-9

    If((Value(TextInput1.Text)>=1&&Value(TextInput1.Text)<=9)=false,Set(var1,Substitute(TextInput1.Text,"0",""));Reset(TextInput1))

    user could only enter text that only has 1-9 number

    If(0 in TextInput1.Text,Set(var1,Substitute(TextInput1.Text,"0",""));Reset(TextInput1))

     

     

    Best regards,

  • cchan000 Profile Picture
    359 on at

    @v-yutliu-msft 

     

    thanks, still new here but where do i put into? what property box?

     

     

     

    Value(TextInput1.Text)>=1&&Value(TextInput1.Text)<=9 

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