Wednesday, May 21, 2008

URL Validation With Javascript

Hi friends. in this post i will explain How can we Validate Web abbress. Once upon i want regular expression in my application which can eliminate full url like (http://www.google.com Not just www.google.com) i tried hard to find but i cant. so i have to develop my own. This is the function i have used:
function ValidateURL(url) { var regexp=new RegExp('^(http[s]?://ftp://)(w{3}\.{1})([A-Za-z0-9]+\.{1}) (comedugovintmilnetorgbizarpainfonameproaerocoopmuseum([a-zA-Z]{2})) ((\.{1})([A-Za-z0-9]{2,3}))?$'); if(!url.match(regexp)) { alert('Please Enter a valid URL: For Eg. "http://somesite.com" or "http://www.somesite.co.in" '); return false; } } You can refer Below Post for develop your own Regular expression on article Regular Expression Syntax & use in ASP.Net C#.Net