The regex you have posted does not really do what you think it does. If you post this into a regex tool like:
Then you will be able to debug your regex, but basically what you have is a match for either
www. so in your case
www.google.co is perfectly valid.
js/prototype/validation.js offers two different url validation options.
- validate-url - which requires either http:// https:// or ftp://
- validate-clean-url - which will work without the protocol,
So to make your regex work with the protocol you can use the following:
But be warned that this will also match
http://a which I guess you do not want it to do.