FANDOM


This function validates a URL using regular expressions. You can specify the prefixRequired parameter (set it to true) to force the function to only accept URLs starting with http://, https://, or ftp://, otherwise this prefix will be optional.



function isUrl(str, prefixRequired) {
  strExp = '^(((http(s?))|(ftp))\:\/\/)';
  if (arguments.length == 1 && arguments[1] != false) strExp += '?';
  strExp += '(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(\.[a-z]{2,4})'
          + '(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$';
  objRegExp = new RegExp(strExp);
  return objRegExp.test(str);
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.