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 / How do I validate acce...
Power Apps
Suggested Answer

How do I validate accept certain URLs being entered into a form.

(1) ShareShare
ReportReport
Posted on by 301
I have a DataCard with a text field on my Power Apps form, which users utilize to enter in URLs. I want to be able to check the URLs they input at real time. Certain URLs should not be entered. Right now on the Visible property of the ErrorMessage label for the DataCard, I have the following to ensure that they are entering in a valid URL format and not just any text...
 
If(
	IsBlank(URLColumnValue.Text), 
	false, 
	If(
		!IsMatch(
			URLColumnValue.Text,
			"(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$"
		), 
		true
	)
)


 
This part is working just fine. I also have a button on the form that allows the users to submit data, and in the DisplayMode of the button, I have the following...
 
If(
	!IsMatch(
		URLColumnValue.Text, 
		"(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$"
	), 
	DisplayMode.Edit, 
	DisplayMode.Disabled
)

 
This works in ensuring that the users enter in a valid URL format. However there are some URLs that are no longer allowed and I want to be able to check that they are not entering those URLs that are not accepted anymore.  
 
Below are example URLs that should be accepted...
 
https://myDomain/site/ABCsite
https://myDomain/site/ABCsite1
https://myDomain/site/ABCsite2

 
 
While anything like these, should not be allowed. 
 
https://myDomain/teams/ABCsite
https://myDomain/teams/ABCsite1
https://myDomain/teams/ABCsite2
https://myDomain/site/XYZsite
https://myDomain/site/XYZsite1
https://myDomain/site/XYZsite2

What would be the best way to implement such a logic, so that I can keep the current functionality while users are not able to submit anything in the format for the banned URLs?
Categories:
I have the same question (0)
  • Suggested answer
    ANB Profile Picture
    7,223 Super User 2025 Season 2 on at
     
    You can try below code, if you are sure that the URL should not have exact keywords like in above example you mentions: teams and XYZ.
     
    Then you can try below code:
    If(
    	!IsMatch(
    		URLColumnValue.Text, 
    		"(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$"
    	) And (!("teams" in URLColumnValue.Text) Or !("XYZ" in URLColumnValue.Text)), 
    	DisplayMode.Edit, 
    	DisplayMode.Disabled
    )
     

    Please click Does this answer your question 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 a Like.


    Thanks,
    ANB

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 342 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard