Answers for "check if valid url javascript"

1

Check if a JavaScript string is a URL

function isValidURL(string) {
  var res = string.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);
  return (res !== null)
};

var testCase1 = "http://en.wikipedia.org/wiki/Procter_&_Gamble";

alert(isValidURL(testCase1));
Posted by: Guest on December-02-2020
-1

validate url in javascript

validate url
Posted by: Guest on May-19-2021

Code answers related to "check if valid url javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language