Validating a URL

g4gxl 06 Feb, 2008
I am using the built in validation.

It's working fine although someone has commented that a web address like www.chronoengine.com should pass validation.

Currently the format must be http://www.chronoengine.com, without the http:// it is deemed to be invalid.

Is there an easy way to allow addresses without the prefix to pass validation ?
GreyHead 06 Feb, 2008
Hi g4gxl,

Well, <!-- w --><a class="postlink" href="http://www.chronoengine.com">www.chronoengine.com</a><!-- w --> isn't a valid url - your browser will probably accept it OK because they have some tolerance built in. But that doesn't make it valid. If you accept <!-- w --><a class="postlink" href="http://www.chronoengine.com">www.chronoengine.com</a><!-- w --> as valid will you also accept other prefixes like test.chronoengine.com or just chronoengine.com?? Then it gets really hard to be sure what is valid.

If you want to accept these non-urls then I expect that it would be fairly easy to hack the validation javascript. Though it might be better to add a note to the input box saying that the http:// is required, maybe even put it as the default value for the field.

Bob
This topic is locked and no more replies can be posted.