cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rohitsekar1996
Helper I
Helper I

Condition only number to be typed

Hi Everyone,

I have textbox were users are allowed to type only numbers. No texts, and special characters allowed so when user types any letter or Special characters I want to show users a notification that only numbers are allowed. To achieve above condition I have created a label with Text "Only numbers are allowed" but I want formula so I cant add the Condition in Visible property of Label to notify the users. Is there a way to achieve this. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @rohitsekar1996 ,

Do you want to validate whether data in a textinput only has number?

If so, I suggest you use IsMatch function, which could justify whether data meet the format that you want.

I've made a similar test for your reference:

1)insert a textinput for entering data

2)insert a label to display "Only numbers are allowed" when not meeting requirement

set the label's Text:

"Only numbers are allowed"

set the label's Visible:

!IsMatch(TextInput1.Text,"[0-9]+")&&!IsBlank(TextInput1.Text)
//[0-9] means only allows number
+ means zore to more

Then if you enter  texts or special characters, the text will display.

3)insert a button to submit data.

Set the submit button's OnSelect:

If(!IsMatch(TextInput1.Text,"[0-9]+"),
Notify("Only numbers are allowed",NotificationType.Warning),
Patch(....)
)

//when not meet requirement, you will not submit data and get a notification.

 

 

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

2 REPLIES 2
Drrickryp
Super User II
Super User II

Hi @rohitsekar1996 

You could set the Format property of the control to TextFormat.Number and put "This box only accepts numbers" in the hint text. It will accept both integers and decimals. As an alternative, I would recommend the Slider control.  You can set the number limit for Default, Min and Max.  My preference is to give users as few options for entering data as possible, To see more about the slider,

ref https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-slider 

For a discussion regarding the TextInput control and limiting it to integers only see https://powerusers.microsoft.com/t5/Building-Power-Apps/Forcing-Integer-input-for-a-Text-Input-Contr... 

 

v-yutliu-msft
Community Support
Community Support

Hi @rohitsekar1996 ,

Do you want to validate whether data in a textinput only has number?

If so, I suggest you use IsMatch function, which could justify whether data meet the format that you want.

I've made a similar test for your reference:

1)insert a textinput for entering data

2)insert a label to display "Only numbers are allowed" when not meeting requirement

set the label's Text:

"Only numbers are allowed"

set the label's Visible:

!IsMatch(TextInput1.Text,"[0-9]+")&&!IsBlank(TextInput1.Text)
//[0-9] means only allows number
+ means zore to more

Then if you enter  texts or special characters, the text will display.

3)insert a button to submit data.

Set the submit button's OnSelect:

If(!IsMatch(TextInput1.Text,"[0-9]+"),
Notify("Only numbers are allowed",NotificationType.Warning),
Patch(....)
)

//when not meet requirement, you will not submit data and get a notification.

 

 

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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (18,527)