cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

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
Highlighted
Community Support
Community Support

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
Highlighted
Super User
Super User

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

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

Highlighted
Resident Rockstar
Resident Rockstar

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. 

Highlighted
Community Support
Community Support

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

Highlighted
Helper V
Helper V

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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