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 / Format TextInput to ac...
Power Apps
Answered

Format TextInput to accept number only with "."

(0) ShareShare
ReportReport
Posted on by 87

Hello,

I am building a power app where the users have to enter the time they worked on a project and store it in a SharePoint list. They can enter integers or float numbers.

My issue is that some users must use commas and some use dots ( 1,5 or 1.5 ) and I have been asked to make it so everyone uses the same format but when I force the usage of the dot then the users that needed comma get their hours as integers when patching ( 1,5 becomes 15 ).

 

Is it even possible to achieve this or is it tied to the local settings of each user?

Categories:
  • VishalJhaveri Profile Picture
    1,169 Moderator on at

    Now, to achieve this requirement, Convert the text input control such that it accepts only Number in its FORMAT property.

    VishalJhaveri_0-1678954913281.png

    On doing this change, the user might be restricted to use the comma in text input control. Also it would be advisable to add a hint text in the text input control so that which facilitates the user to know the exact format of the number.

    Text input control in Power Apps - Power Apps | Microsoft Learn

    Now, I guess this should definitely work and fulfill your requirement.

    Thank you.
    If my answer helps you, please mark it as solution.

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    This won't solve the issue. The number format uses the local number format for the user, and won't be consistent.

     

    @IonutHzd give me a few minutes and I'll have a proof of concept for you that strips out other characters from a text-format text input

  • Verified answer
    iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Ok, so you'll need a timer, a label to display the error message (for when they use more than one . (period) - then you can get it to strip out all characters except those that are valid.

     

    TextInput.Default:

    gblOriginalTextValue

     

    Timer.OnTimerStart:

    Set(gblOriginalTextValue, Concat(Split(TextInput1.Text, ""), Value));
    Set(
     gblOriginalTextValue,
     With({SplitList: Split(TextInput1.Text & ".", "")},
     Coalesce(
     Concat(
     ForAll(Sequence(CountRows(SplitList)),
     If(
     Value = CountRows(SplitList) && Last(FirstN(SplitList, Value)).Value=".", "",
     If(IsMatch(Last(FirstN(SplitList, Value)).Value,
     "[0-9.]"), Last(FirstN(SplitList, Value)).Value, "")
     )
     )
     ,
     Value
     )
     )
     )
    );
    If(CountRows(RemoveIf(Split(gblOriginalTextValue, ""), !IsMatch(Value, "[.]")))>1, Set(ErrorMessageText, "This is not a valid number, please use a period as your decimal separator, only one period is required"), Set(ErrorMessageText, ""))

     

    ErrorMessageLabel.Text:

    ErrorMessageText

     

    Here's it in action:

    TimerPOC2.gif

     

    And at the bottom here you'll find a proof of concept app attached 🙂

     

    Cheers,

    Sancho

  • IonutHzd Profile Picture
    87 on at

    Thank you very much for the suggestion and the demo!

    It didn't fix my problem as the users that needed to use comma still get their number patched as integers but this will be very useful in different projects.

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Did you make the Text Input format Text rather than number? Keeping it as number will still probably end up with it getting used as a locally-formatted number.

    Also, does your Update property of the datacard use the Value() function to store in the datasource as a number, as that will also convert it to a local format number - best to use a text column in the datasource and force the validation in the App (removing the Value reference and just storing the output as the cleaned-up text from my previous example)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 239

Last 30 days Overall leaderboard