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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Trim text before submi...
Power Apps
Unanswered

Trim text before submit form

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    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.

  • sbgoh Profile Picture
    284 on at

    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,923 on at

    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 at

    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,923 on at

    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.

  • Verified answer
    timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    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.

  • sbgoh Profile Picture
    284 on at

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

  • JAWL Profile Picture
    393 on at

    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?

     

     

  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    @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
    393 on at

    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

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard