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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Restrict Special chare...
Power Apps
Answered

Restrict Special charectors in text box except for _ and -

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello All ,

 

 I have a text box which should restrict any special characters entered but accept only A-Z ,a-z,0-9 , hyphen and underscore .

 

 So on the "ON CHANGE " property of my text box I have written the following formula :


If(!(IsMatch(DataCardValue2.Text, "[A-Za-z0-9\_\-]")),Reset(Self))

 

So if any other special charecter is mentioned then the textbox is reset . 

 

But its not working . 

 

Also I have a label to indicate the warning on the "VISIBLE " I have written 

 

(!(IsMatch(DataCardValue2.Text, "[A-Za-z0-9\_\-]"))&& IsBlank(DataCardValue2.Text))

 

Isblank to make sure the text can be blank as well .

 

Can someone help me on the following .

 

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,536 Most Valuable Professional on at

    Hi @Anonymous ,

    I have a blog on an alternative method that may be of use here.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 432 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard