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 / Validation for Special...
Power Apps
Unanswered

Validation for Special Characters

(1) ShareShare
ReportReport
Posted on by 2

Hello,

 

I am working on an PowerApp where there are few fields in which i want a validation that, if a person enters special characters then the form should not get submitted and to show a warning message. For warning message i can use notify function but how to check and act if a field value consisting of special characters? 

 

Regards,

Akshay

Categories:
I have the same question (0)
  • Verified answer
    Joel CustomerEffective Profile Picture
    3,224 on at

    There's a regex for that. Here is an example of doing a up to 9 digit string with no special characters.

     

    IsMatch( "AStrongPasswordNot", "(?!^[0-9]\*$)(?!^[a-zA-Z]\*$)([a-zA-Z0-9]{8,10})" )

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-ismatch

     

    @AkshayManke if this answers your question, please mark it a solution. 

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    on at

    Hi@AkshayManke,

    Based on the issue that you mentioned, do you want to disable the submit button if there is any special characters in the TextInput?

    As @jlindstrom said, IsMatch() can achieve your needs, I have a test on my side, please take a try as below.

    Set the OnChange property of the corresponding DataCardValue to TextInput control as below.

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

    To warn the user the invalid characters, add a Label and set the following Text, Visible property as below

    Text property: "Special characters are not allowed!"
    Visible property: IsMatch(DataCardValue6.Text,".*[\\\"&Char(34)&"].*")

     Set the DisplayMode property of the submit button as below

    If(
     !Label5.Visible,
     Edit,
     Disabled
    )

    Note: Special character in my test are "\" and double quote, you can replace it with yours.

    You can check the GIF for reference.

    0723Gif2.gif

    Best Regards,

    Qi

     

  • AkshayManke Profile Picture
    2 on at

    Hi @jlindstrom@v-qiaqi-msft,

     

    The solution given by both of you worked. I have implemented it in my App.

     

    Many thanks to both of you..!!

     

    Accepting both's solutions!

     

    Regards,

    Akshay

  • GixStar Profile Picture
    6 on at

    Thank you this was very help full !!

    one question how do i disable the button if i have 2 Labels , if either one of them are showing invalid character message. i tried this below it only blocks the button if both Lables are showing. 

     

     

    If(
    !Label4 && !Label6.Visible,
    Edit,
    Disabled 

     

    Thank you 

  • AkshayManke Profile Picture
    2 on at

    Hi @GixStar ,

     

    You can try replacing '&&' with 'Or' and see if that works.

     

    && will check if both the conditions are true whereas Or will check of any of the condition is true.

     

    Share the result.

     

    Kind Regards, 

    Akshay

  • jrtraylor Profile Picture
    45 on at

    @v-qiaqi-msft 

    How can i modify your formula to allow for 4 characters? I need to allow Char(38), Char(45), Char(46) and Char(95) in my text box.

  • GixStar Profile Picture
    6 on at

    Hi 

    i tried that but its still only disabling the Submit button if Label4 and Label6 has invalid characters, if one of them have invalid Characters Submit button is still active.

    Thank you 

     

    If(
    !Label4.Visible Or !Label6.Visible,
    Edit,
    Disabled

    )

  • AkshayManke Profile Picture
    2 on at

    Hi @GixStar ,

     

    I think you can just add parenthesis in the two conditions like below.

    If(
    !(Label4.Visible) Or !(Label6.Visible),
    Edit,
    Disabled

    )

     

    I have created a test on my env. you can refer the below GIF for the same.

     

    Condition.gif

  • Dado90 Profile Picture
    2 on at

    Works really well for me. 

    With this onchange-code i can block the special characters Char(34) and Char(47).

     

    Now my new problem is, as soon as someone set a new line in de multiline datacardvalue-field by clicking the enter-button, the code is like not activ anymore. 

     

    does anybody knows how the ismatch is working when enter-button for a new line is clicked in an multiline datacardvalue-field?

     

    Thanks

  • RM-30040732-0 Profile Picture
    518 on at

    Hello! Do you have any idea how to set your Ismatch to find all special characters (without specifying each one)? And how to find spaces?  I'm trying to validate entries that only contain letters or numbers and can't get Ismatch to work!

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard