Validate URL

Posted by Venkat | Labels: ,

Validate URL 

<asp:RegularExpressionValidator 
            ID="RegularExpressionValidator1"
            runat="server" 
            ValidationExpression="(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?"
            ControlToValidate="TextBox1"
            ErrorMessage="Input valid Internet URL!"
            ></asp:RegularExpressionValidator> 
 
Here i update the Regex this will accept the URL like:
http://regxlib.com/Default.aspx | http://electronics.cnet.com/electronics/0-6342366-8-8994967-1.html 

2 comments:

  1. Unknown said...:

    This is not correct Validation.. try to validate http://www.mydomain with this, it doesnt work

  1. Venkat said...:

    @vivs

    Yes, I updated the REGEX Check it.

Post a Comment

Thanks for the Comments.

PayOffers.in