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 make a text i...
Power Apps
Answered

How do I make a text input throw and error if the format is not correct?

(0) ShareShare
ReportReport
Posted on by 831 Moderator
I have a text input where the user needs to enter a URL. I want to do very basic checking to make sure they have included a "https://" or "http://" at the beginning. I can get there using this code however it resets the field and means the need to re-type or re-copy and paste the URL back into the field. I would prefer for them to just edit what they put in the field. How can I make this happen?
 
If(
    !StartsWith(TXT_BaseURL.Text, "https://") || !StartsWith(TXT_BaseURL.Text, "http://"),
    Reset(Self);
    Notify("Invalid URL: ULR must start with https:// or http://")
)
Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    68,707 Most Valuable Professional on at
    Instead of using a StartsWith I would use an IsMatch with an REGEX expression in the OnChange action of the text input control.
     
    Here's an article on how to use REGEX to raise an error in a Card in a Form control that uses a text input. Power Apps Text Input Pattern Validation - @WonderLaura
  • futr_vision Profile Picture
    831 Moderator on at
    This largely works. I had to make changes to several areas in the app because the field is not set to invalid. For example, the Submit button is looking in Disabled mode until the form is valid. All that matters in this case is that the field in question has some type of input in it. I had to update the Required field of the data card that held the text input field to also check to see if there was an 'https://' or 'http://' before allowing the data card to be set to required. This is the code I used.
     
    If(
        !IsMatch(TXT_BaseURL.Text,"^(https?://)"), true , false
     )
     
    This works but it is incorrect. The field should always be required which this code does not say. Is there a better way to do this?
     
  • futr_vision Profile Picture
    831 Moderator on at
    Nevermind. I can leave the datacard set to true for Required and it works fine. I am guessing but is pushing and error notification signaling that the form is not valid ?

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard