tags:

views:

266

answers:

3

I think the question title seems to explain eveything. I want to detect whether a string is in URL format or not using javascript.

Any help appreciated.

+1  A: 

try this: http://snippets.dzone.com/posts/show/452

Mark Redman
+5  A: 

try something like this:

function isUrl(s) {
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)? (\/|\/([\w#!:.?+=&%@!\-\/]))?/
return regexp.test(s);
}

taken from http://snippets.dzone.com/posts/show/452

Anthony Forloney
A: 

You can use a regular expression for checking the string

^s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+$

Regular Expressions and Javascript

Shoban