Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Validate A Url (regexp)

DZone's Guide to

Validate A Url (regexp)

·
Free Resource

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


usage: if (isUrl("http://www.page.com")) alert("is correct") 
       else alert("not correct");
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}