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 / Validating a URL enter...
Power Apps
Answered

Validating a URL entered in a textbox

(0) ShareShare
ReportReport
Posted on by 634

I'm trying to figure out a slick way of validating a URL being entered into a text box.

 

I've found tutorials that say do something like this in the border color property

 

 

IsMatch(URL_Input.Text, "(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$")

 

 

or something like this in the Required property

 

 

 

If(!IsBlank('Base URL TB'.Value) && IsMatch('Base URL TB'.Value, "(?:http(s)?:\/\/)?[\w.-]+(?:.[\w.-]+)+[\w-._~:/?#[]@!\$&'()*+,;=.]"),true,false)

 

 

 

Nothing seems to work quite right. Any ideas?

Categories:
I have the same question (0)
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@Future_Vision,

    Based on the issue that you mentioned, do you want to validate the string entered in the TextInput?

    Could you please share a bit more about the scenario, where do you want to set for the validation formula?

    I have a test on my side, please take a try as below.

    The first formula you provided is not completed, please modify your formula set in the BorderColor property as below:

     

    If(
     !IsBlank(TextInput1.Text),
     If(
     IsMatch(
     TextInput1.Text,
     "(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$"
     ),
     Green,
     Red
     ),
     RGBA(
     166,
     166,
     166,
     1
     )
    )

     

    Note: If you enter a valid URL, the border color will be green.

    The second formula you provided is set for the Required property of a data card within a form. If you have a single TextInput, you could not find a Required property within. 

    Regards,

    Qi

  • Future_Vision Profile Picture
    634 on at

    What I am thinking is validating the TextInput as the user types or pastes in the URL . I would also want to prevent the form from submitting if they do not input a valid URL.

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@Future_Vision,

    Do you want to validate the input once someone enter something and disable the submit function if someone try to submit the invalid URL?

    Here is a workaround you can check for reference.

    Add a Label up or down the TextInput and set the Text property as below:

    "Please enter a valid URL!"

    Set the Visible property of the Label as below:

    If(
     IsBlank(DataCardValue10.Text),
     false,
     If(
     !IsMatch(
     DataCardValue10.Text,
     "(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$"
     ),
     true
     )
    )

    Note: DataCardValue10 represents the TextInput control.

    Set the DisplayMode property of the submit Button as below:

    If(Label3.Visible=true,Disabled,Edit)

    54.png

    Regards,

    Qi

  • Future_Vision Profile Picture
    634 on at

    I am looking for functionality just like any other form validation. When you click the button it won't submit unless the field is properly filled out. Having real-time validation notification, as the user enters the URL, would be nice too.

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@Future_Vision,

    Do you want the form to pop up the error notification and have a  real-time validation notification for the TextInput where you enter the URL?

    // If you just want a real-time validation notification once you enter in the TextInput, please check the solution I provided before.

    // If you want the form to pop up a notification when you try to submit a invalid URL, please try as follows.

    Add a Label (named "Label3" ) up or down the TextInput and set the Text property as below:

    "Please enter a valid URL!"

    Set the Visible property of the Label as below:

    If(
     IsBlank(DataCardValue10.Text),
     false,
     If(
     !IsMatch(
     DataCardValue10.Text,
     "(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$"
     ),
     true
     )
    )

    Note: DataCardValue10 represents the TextInput control.

    set the OnSelect property of the submit button as below:

    If(
     Label3.Visible = true,
     Notify(
     "Please enter a valid URL and try again!",
     NotificationType.Error
     ),
     SubmitForm(Form1)
    )

    56.png

    Regards,

    Qi 

  • Future_Vision Profile Picture
    634 on at

    I don't really want anything special. I want the typical warning you get under a form field when it is required but does not validate and real-time validation that says the URL is not valid until it becomes valid.

  • Future_Vision Profile Picture
    634 on at

    I added the code to the Visible property but I noticed that the validation falls down in some circumstances. For example this validates as a legitimate website 'http://www.sz' even though it shouldn't.  I could also do something like 'co.co.co.co.co' and this also validates to a legitimate website. Any fixes for this?

     

    I'm guessing I might need to include some additional specificity to the URL requirement to get a more appropriate RegEx. For example the URL needs to always include http:// or https://. And if there is a 'www. then there must be a second '.' followed by at least 2 value charachters.

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@Future_Vision,

    I want to explain to you that the "www" is a domain name, you could not force a second dot to be added followed by the characters that is just followed by the "www."

    So if you expect that there is a "www," and there must be a second dot followed by at least 2 characters, I am afraid that there is no way to achieve this using the regular expression.

    From now on, we could only make the URL validation valid as below:

     

    http(s)?:\/\/(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}\.([a-zA-Z0-9][-a-zA-Z0-9]{1,62})+

     

    This would make the URL start with the http:// or https://. And if there is a "www." occurs, once you enter the second dot, you should enter at least 2 characters.

    //From here on out is where I re-edit.

    I've rethought it again, taking into account your needs. To achieve your needs, I think we only need to use a portion of the regular expressions and the next part needs to be combined with the relevant functions of PowerApps.

    I don't think use the Require property to valid the URL is a good choice, use notification when you submit the form is much more efficient.

    Please set the OnSelect property of the submit button as below:

    If(
     "www." exactin TextInput3.Text,
     If(
     CountRows(
     Split(
     TextInput3.Text,
     "."
     )
     ) >= 3 && Len(
     Last(
     Split(
     TextInput3.Text,
     "."
     )
     ).Result
     ) >= 2 && IsMatch(
     TextInput3.Text,
     "http(s)?:\/\/(www\.)?\S*"
     ),
     SubmitForm(Form1),
     Notify(
     "Invalid URL!",
     NotificationType.Error
     )
     ),
     If(
     IsMatch(
     TextInput3.Text,
     "http(s)?:\/\/(www\.)?\S*"
     ),
     SubmitForm(Form1),
     Notify(
     "Invalid URL!",
     NotificationType.Error
     )
     )
    )

    Note: Anytime the user enter an invalid URL, the form could not be submitted.

    Here is the original formula that validate the URL:

    If(
     "www." exactin TextInput3.Text,
     CountRows(
     Split(
     TextInput3.Text,
     "."
     )
     ) >= 3 && Len(
     Last(
     Split(
     TextInput3.Text,
     "."
     )
     ).Result
     ) >= 2 && IsMatch(
     TextInput3.Text,
     "http(s)?:\/\/(www\.)?\S*"
     ),
     IsMatch(
     TextInput3.Text,
     "http(s)?:\/\/(www\.)?\S*"
     )
    )

    Regards,

    Qi

     

  • Future_Vision Profile Picture
    634 on at

    Does this still allow for the other fields to be checked by the "Required" function of those datacards?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 103

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
wolenberg_ Profile Picture

wolenberg_ 67 Super User 2026 Season 1

Last 30 days Overall leaderboard