web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Number text format don...
Power Apps
Answered

Number text format dont allow decimals or negatives

(2) ShareShare
ReportReport
Posted on by Microsoft Employee

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.

Categories:
I have the same question (0)
  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @Anonymous 
    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." 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @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

     

  • mdevaney Profile Picture
    29,991 Moderator on at

    @Anonymous 
    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."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @mdevaney 

     

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

  • mdevaney Profile Picture
    29,991 Moderator on at

    @Anonymous 
    Yes, that works too.

  • sahrastolz Profile Picture
    30 on at

    Set the "On Change" property of the input to 

     

    If(
    Value(Self.Text) < 0,
    Set(
    varcorrected,
    "0"
    ),
    Set(
    varcorrected,
    Text(
    Round(
    Value(Self.Text),
    0
    ),
    "0"
    )
    );
    Reset(Self)
    )

     

     

    Set the default value of the input to

    varcorrected.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
wolenberg_ Profile Picture

wolenberg_ 119 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 107 Most Valuable Professional

#3
Haque Profile Picture

Haque 103

Last 30 days Overall leaderboard