cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User III
Super User III

@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
Super User III
Super User III

@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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (24,388)