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.
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.
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, " ", "")
Hi @timl I have tried using trim in the Update Property of DataCard but it does not work.
I tried Trim(Value(DataCardValueTO.Text) but Submit Form is failed with error:
Thus, what is the correct workaround to trim out the spaces in the DataCard?
I see. It is the update property. Got it. I will try. Thanks a lot! 🙂
Hi @sbgoh
The way I would do this is to apply the Trim function on the update property of the card for your field.
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.
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.
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 ".
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.
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!
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.
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional