Skip to main content

Notifications

Community site session details

Community site session details

Session Id : SieaZCQL2cN7lJMR6cairh
Power Apps - Building Power Apps
Answered

Trim text before submit form

Like (0) ShareShare
ReportReport
Posted on 30 Jun 2020 09:08:54 by 284

Hi,

Is it possible to trim the text that user input before submit form?

I tried with "Field.Text = trim(Field.Text)" and update context but it seems not working.

Categories:
  • JAWL Profile Picture
    391 on 08 Mar 2022 at 00:58:38
    Re: Trim text before submit form

    Hi @timl

     

    Thanks, your tip works (removing spaces upon Submit Form). Nevertheless, is there a way to prevent user inputting space into the DataCardValue (Column type: Text)? I know I can set error notification to detect if user inputs space but I want to DISABLE user's ability to input Space. 

     

    JAWL_0-1646701023616.png

     

  • timl Profile Picture
    34,941 Super User 2025 Season 1 on 07 Mar 2022 at 10:58:53
    Re: Trim text before submit form

    @JAWL 

    If you want to remove all spaces from the input string, (eg - convert "12 12" to "1212"), you can do this with the Substitute function.

    https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-replace-substitute

     

    Substitute(DataCardValueTO.Text, " ", "")
  • JAWL Profile Picture
    391 on 07 Mar 2022 at 09:40:09
    Re: Trim text before submit form

    Hi @timl I have tried using trim in the Update Property of DataCard but it does not work.

    JAWL_0-1646645859518.png

     

    I tried Trim(Value(DataCardValueTO.Text) but Submit Form is failed with error:

    JAWL_1-1646646002621.png

     

     

    Thus, what is the correct workaround to trim out the spaces in the DataCard?

     

     

  • sbgoh Profile Picture
    284 on 30 Jun 2020 at 10:02:59
    Re: Trim text before submit form

    I see. It is the update property. Got it. I will try. Thanks a lot! 🙂

  • Verified answer
    timl Profile Picture
    34,941 Super User 2025 Season 1 on 30 Jun 2020 at 10:01:42
    Re: Trim text before submit form

    Hi @sbgoh 

    The way I would do this is to apply the Trim function on the update property of the card for your field.

    image.png

    In your case, you would set it to Trim(Field.Text).

    Once you do this, your SubmitForm function should submit the record and trim the field.

  • eka24 Profile Picture
    20,921 on 30 Jun 2020 at 09:56:13
    Re: Trim text before submit form

    Then it should be Trim(txtField.Text)

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • sbgoh Profile Picture
    284 on 30 Jun 2020 at 09:52:25
    Re: Trim text before submit form

    I have a textbox in a edit form named "txtField". I want to trim spaces in the text entered my user upon clicked "Submit" button.

    E.g. if user entered "    MAX   ", I want to submit "MAX" instead of "    MAX   ".

  • eka24 Profile Picture
    20,921 on 30 Jun 2020 at 09:47:31
    Re: Trim text before submit form

    Can you be more specific on what you want to do. What are you trimming and in what textbox?

    Trim(Field.Text) is ok. Field should be a textbox name on your form not a column in the table

    If you are not ok, give a screen shot.

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • sbgoh Profile Picture
    284 on 30 Jun 2020 at 09:39:56
    Re: Trim text before submit form

    I used tried this 2 method:

    1. Field.Text = trim(Field.Text); SubmitForm(FrmName)

    2. UpdateContext(Field.Text: Trim(Field.Text); SubmitForm(FrmName)

     

    Both ways does not help. Any advise? Thanks!

  • eka24 Profile Picture
    20,921 on 30 Jun 2020 at 09:20:45
    Re: Trim text before submit form

    Trim(Field.Text) is ok but how did you use it with the update context.

    Can you give more details

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard