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

Number text format dont allow decimals or negatives

I have a data card field that I have set to Format: TextFormat.Number

 

However, when testing this it works perfect for preventing users inputting strings but if they enter negative(-12) or decimal (2.4)

it still work.

 

For this field I need the input to be whole number only. How may I check and then round the decimals or trim the - symbol? 

 

I can make warning signs and don't let them press submit. But I would really prefer to limit what can be typed in.

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@miss_haley 
You have to make 'warning signs' as you mentioned.  There's no way to prevent typing a valid number.

 

You can restrict input values by using another control type like a pre-defined dropdown of numbers or a Slider control.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

View solution in original post

5 REPLIES 5
mdevaney
Super User
Super User

@miss_haley 
You have to make 'warning signs' as you mentioned.  There's no way to prevent typing a valid number.

 

You can restrict input values by using another control type like a pre-defined dropdown of numbers or a Slider control.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

View solution in original post

@mdevaney 

 

to check for negative and show error I can type

If(Value(TextInput1.Text) < 0)

 

Would you know how I can check for the decimal?

I dont know how I can check if "." exist in the textinput

 

@miss_haley 
I think you can check for a decimal like this

Mod(your_number_here, 1)<>0

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

@mdevaney 

 

Thanks for reply, I use the IsMatch function and look for decimal as a regex pattern it work. 

@miss_haley 
Yes, that works too.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,571)