View Full Version : regular expression validation for url

09-04-2008, 11:46 AM
Hi all,

Please help in validating url like -
And it should not check for (http://) using regular expression.
I am trying but finding difficult to solve it :confused:


Philip M
09-04-2008, 12:53 PM
if(/www\.[a-z0-9][a-z0-9\-]{0,61}[a-z0-9]\.[a-z\.{2,6}]$/gi.test(url.value)) { // return true

This permits but does not require characters (such as http://) before the www.

The only valid characters for a domain name are letters, numbers and a hyphen "-". Hyphens may be anywhere in the middle of a name, but can not be located at the end or beginning of a name. A valid domain name does not have spaces. The domain name without the extension can be up to 63 characters.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.