website expression validator

hi all.....

how can i check the website whether it is in valid format / type when user input the webiste url in the textbox....

the code below is used to check email expression

Regex.IsMatch(txtEmail.Text, _
"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\] )$") = False

but i can't find out the website expression in visual baisc.......

please let me know if anyone got the solution....

thanks



Answer this question

website expression validator

  • vai23

    thanks for u replies

    i have found out the sulution.........i check the url by using the code below..

    If Not txtWebsite.Text = "" And Regex.IsMatch(txtWebsite.Text, "http://([\w-]+\.)+[\w-]*(/[\w- ./ %=]*) ") = False Then
    epAddMerchant.SetError(txtWebsite, "Invalid website type")

    Else
    epAddMerchant.SetError(txtWebsite, "")
    End If

    hopefully this will help others who need this expression...

    thanks


  • XnakX

    An easier way is to do a DNS lookup. I'm not sure what your looking for though, do you want to know if the URL is malformed or just if the page exists

  • Chris Vega

    hehehe,

    There's another really good way to do it. Take advantage of a couple of the small black boxes:

    This is a couple of lines from a function that among other things validates a URL:

    Dim a As Uri
    Try : a = New Uri(URL) : Catch : Return Nothing : URL = Nothing : End Try

    The function returns Nothing if the input string is not a valid URL string. It continue processing if is valid.



  • SpawnProduction

    thanks ReneeC

    i have tried this function.....but it seem like did not work for me........

    maybe i should use the regular expression of website to check it....

    thanks


  • website expression validator