hi i have a jquery validation method for URL validation ,
currently i use a validation rule like this
var urlregex = new RegExp("^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
var urltest=urlregex.test(url);
this validates
1 . http://abcd to true .
2 . http://abcd.com to true .
3 . http://www.abcd to true .
4 . http://www.abcd.com to true .
i want to be true only the 4 th URL .
i want a validation that needs
www with http:// (or like https:// , ftp://) and to end with .com (or like .org , .lk)
only URL’s like this should validate true
http://www.abcd.com
http://www.efgh.lk
please help . thanks in advance ……………………
Try this regex:
Update
Regex object initialization + unlimited number of subdomains + upto 4 characters in root domain: