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 / Validate a text field ...
Power Apps
Answered

Validate a text field in PowerApp Form

(0) ShareShare
ReportReport
Posted on by 219

Hi

I am using PowerApp Form with 19 Text Fields where users provide input and submit the Form to SharePoint list. Then a page gets created(using Flow) in the SitePages library of SharePoint site with all the dynamic text values provided by users . Everything is working fine until I realised that when users are using "(double quote) or \(backslash) special characters, the Flow is getting failed with Bad Gateway error.

Is there anyway I can do in PowerApps text fields where users are not allowed to enter  "(double quote) and \(backslash) ??

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

    @SumanthDundi7 

    You can detect if a user input a blackslash ( \ ) or and double quote ( " ) using this code

     

    IsMatch(TextInput1.Text,".*[\\\"&Char(34)&"].*")

     

    Input of these characters into the text field cannot be prevented but you can alert the user when an error is made.  Create an label for each input field to display an error message when the illegal character is input.  Name the labels: emsg1, emsg2, emsg3... emsg19

     

    Text: "The symbols \ or "&Char(34)&" are not allowed."
    Color: Red
    Visible: IsMatch(TextInput1.Text,".*[\\\"&Char(34)&"].*")

     

    Finally, you should prevent the user form submitting the form when any error messages are displaying.  Put this code in the DisplayMode property of your submit button

     

    If(
     And(
     !emsg1.Visible,
     !emsg2.Visble,
     !emsg3.Visible
     ...
     !emsg19.Visible
     ),
     Edit,
     Disabled
    )

     

    Note:  where you see the three dots ... in my examples you should write out all the labels for 1-19.

     

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

  • datamaster Profile Picture
    250 on at

    You can also simply just use the Replace and Substitute functions in PowerApps before submitting.

     

    ------------------------------------------------------------------------------OfficePowerUser.com------------------------------------------------------------------------ 
    If this post helps answer your question, please click on “Accept as Solution” to help other members. If you thought this post was helpful, please give it a Thumbs Up. 

     

     

     

  • SumanthDundi7 Profile Picture
    219 on at

    @mdevaney 

     

    Thank you very much for the solution. It worked. But instead of inserting labels for error messages, I have added code and made changes as per my requirement to the default error message labels created by PowerApps itself for every data cards. 

     

    Can you please also help me in understanding in bits & pieces the expression (".*[\\\"&Char(34)&"].*") ???

  • mdevaney Profile Picture
    29,989 Moderator on at

    @SumanthDundi7 

    ".*[\\\"&Char(34)&"].*"is called a regular expression.  Regular expressions define a pattern to be found in a text string.  ISMATCH returns true when the pattern is found in a text string and false when the pattern is not found.  This particular regular expression says

     

    • look for the text starting with 0 or more of character
    • then a \ or & is found in the middule
    • finally it ends with 0 or more of any character

     

    If you want to learn how to do this you can take a free 1 hour course at this website.  Its really fun and its how I learned.

    https://regexone.com/

     

    Don't forget to mark my original post as the solution please 😄

     

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

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard