cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cchan000
Level: Powered On

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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

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

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
PowerBack19
Level 8

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

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

EricLott
Level 10

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

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. 

Community Support Team
Community Support Team

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

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

cchan000
Level: Powered On

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

@v-yutliu-msft 

 

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

 

 

 

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

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,503)