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?