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:
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
2010-06-05 12:07:48
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
2010-06-23 14:08:03