views:

43

answers:

4

How to validate Internet address in asp.net mvc textbox like www.gmail.com or http://www.hotmail.com I want to implement jquery client side validation

A: 

If you just want to parse it, take a look a the Uri class.

Alex
A: 

I think this will help.

Anil Namde
A: 

I would suggest using jQuery Validation Plugin (which has build in url validation rule) with ASP.NET MVC 2 model validation. Here you can read how to create an asynchronous form in ASP.NET MVC which uses DataAnnotations and jQuery Validation Plugin (it also shows how to create validators which make use of built in client side rules of this plugin)

tpeczek
A: 

Here is a good way to validate internet address

var address = $('#vcr_LinkAddress').val();
var j = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
if (!j.test(address)) {
//If address is invalid
}
else
{
//address is valid
}
Fraz Sundal