cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

Validation for Special Characters

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

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User III
Super User III

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. 

View solution in original post

Highlighted
Microsoft
Microsoft

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

 

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

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. 

View solution in original post

Highlighted
Microsoft
Microsoft

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

 

View solution in original post

Highlighted

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,865)