showing results for - "validate url in javascript"
Jimmy
21 Sep 2017
1function validURL(str) {
2  var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
3    '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
4    '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
5    '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
6    '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
7    '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
8  return !!pattern.test(str);
9}
Martina
05 Jan 2021
1function isValidHttpUrl(string) {
2  let url;
3  
4  try {
5    url = new URL(string);
6  } catch (_) {
7    return false;  
8  }
9
10  return url.protocol === "http:" || url.protocol === "https:";
11}
Poul
14 Aug 2020
1validate url
queries leading to this page
url validation in javascriptjavascript regex to verify http urljs check url is validjs check url validjavascript valid urlcheck if string is link javascriptjavascript url validatorjavascript check url is validjs url is validtest if string is uri javascriptcheck for valid urlvalidate url jscheck if string is url javascriptvalidate url javascriptjavascript is url validhow to check for valid ur 3b in node jsjavascript check valid urlurl validation jscheck if valid url es6check if string is url regex jsvalid url check in javascriptjavascript check if a string is a urljavascript check is urljs url validationreact check if url is validhow to valid a url in jscheck url validity jslodash check if string is urihow to check if a url is valid in javascriptjs check valid urlcheck url format in javascripthow to validate url in javascripttypescript check valid urljavascript verify urlgenerate valid url 27s in javascriptcheck if url is valid javascriptjquery check is urlcheck if url is validjavascript check if string is a urlsee if is valid url jshow to check string is url or not in react native check link validity jsjs check uri is validnodejs check if url is validvalidate a valid web address javascriptcheck if url is correctly formatted typescriptcheck if a url is valid in jsreact check if string is urljavascript if is urlcheck if a string is a url vuejs check if string is urlhow to validate a url in javascriptjavascript ensure url is validvalid string on url jsurl validation javascriptverify url jsjavascript check if valid urljavascript is valid url 3fjavascript check https in urljavascript url validatjs validate urlvalid url jsjavascript check url is valid httplink validation in javascriptcheck for a valid url or hostname jscheck if string contains url javascriptcheck url is valid or not javascripthow to check if url is valid in javascriptcheck if a valid link jsverify if text is url javascriptis valid urlvalidate url in javascriptvalidate is valid url jscheck valid url jsjavascript url validationvalidate string as website url javascriptjavascript validate domain with urijavascript check if a url is validcheck for valid url javascripthow to check valid url in javascriptjavascript valide urlisurl 28 29 in javascriptjavascript verify is valid urlhow to check url is valid or not in javascriptjavascript url checker methodurl validator javascriptjavascript check if link is validjavascript is urljavascript check if input is urljs isurljs check if url is validjavascript validate urlreact checkvalid utlcheck if string is url typescriptvalid url format javascripthow to check if something is a valid url javascripturl validation in jsvalidation url javascriptvalidate url in javascript