cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Forcing Integer input for a Text Input Control

Hi,

 

I'm trying to force a Text Input control to accept only integers but it isn't working so far.

Right now I'm using the following code in the OnChange property of the Text Input control:

If(Value(TextInput.Text ) <> RoundDown(Value(TextInput.Text),0),
Set(resetTextBox, true));Set(resetTextBox, false)

The Reset property of this control is set to the resetTextBox variable.

 

Has anyone accomplished this in a different way?

 

 

6 REPLIES 6
Super User III
Super User III

Hi @Anonymous 

Could you explain what it is about your code that doesn't work?

In the test that I carried out, the text input control accepts whole numbers. If the input value includes numbers after the decimal point, the text input control clears itself. Are you expecting some different behaviour?

Dual Super User II
Dual Super User II

Hi @Anonymous 

 

You can try to update the Format property of your TextInput to TextFormat.Number. It will only allow to enter the numbers.
MicrosoftTeams-image (73).png

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi @yashag2255 

I think the issue with the TextFormat.Number format is that it allows fractional numbers (eg 2.55). As I understand, @Anonymous wants to allow only whole Integer numbers.

Dual Super User II
Dual Super User II

Hi @timl , yes there is a limitation where it allows the decimal point but at the same time we can reset the control as soon as a non-number character is identified, user does not need to move out of the control to see the changes/ reset the textbox. And for removing the decimal value, I think the code @Eduardo_GzzC  used will suffice the requirement. 

 
 @Eduardo_GzzC are you getting any error? I tried out your code and it is resetting the text input control when the user clicks out somewhere else on the screen. But with TextFormat.Number, your input will reset as soon as a character is detected.
 
Thoughts?
Anonymous
Not applicable

Hi, thanks for the answers so far. The code is working after I click outside as expected. I just wanted something that prevents even typing the decimal point. Like when you choose a number as a format and it won't accept text.

 

I guess it would have to be like this for the moment until I find a workaround.

Hey @Anonymous 

 

Yes, this is not supported directly. This workaround will work until Microsoft releases more options for the Text Input controls.

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,364)