Skip to content

Instantly share code, notes, and snippets.

@fatihacet
Created October 11, 2011 12:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fatihacet/1277960 to your computer and use it in GitHub Desktop.
Save fatihacet/1277960 to your computer and use it in GitHub Desktop.
URL validator regex
function isUrl(s) {
var regexp = /((http|https):\/\/)?[A-Za-z0-9\.-]{3,}\.[A-Za-z]{2}/;
return s.indexOf(' ') < 0 && regexp.test(s);
}
isUrl('http://fatihacet.com.tr')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment