javascript url check

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)); 

4.5
8
Awgiedawgie 440220 points

                                    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";
console.log(isValidURL(testCase1)); // return true

var testCase2 = "http://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&docid=nIv5rk2GyP3hXM&tbnid=isiOkMe3nCtexM:&ved=0CAUQjRw&url=http%3A%2F%2Fanimalcrossing.wikia.com%2Fwiki%2FLion&ei=ygZXU_2fGKbMsQTf4YLgAQ&bvm=bv.65177938,d.aWc&psig=AFQjCNEpBfKnal9kU7Zu4n7RnEt2nerN4g&ust=1398298682009707";
console.log(isValidURL(testCase2)); // return true

var testCase3 = "https://sdfasd";
console.log(isValidURL(testCase3)); // return false

var testCase4 = "dfdsfdsfdfdsfsdfs";
console.log(isValidURL(testCase4)); // return false

var testCase5 = "magnet:?xt=urn:btih:123";
console.log(isValidURL(testCase5)); // return false

var testCase6 = "https://stackoverflow.com/";
console.log(isValidURL(testCase6)); // return true

var testCase7 = "https://w";
console.log(isValidURL(testCase7)); // return false

var testCase8 = "https://sdfasdp.ppppppppppp";
console.log(isValidURL(testCase8)); // return false

4.5 (8 Votes)
0
4
10
Awgiedawgie 440220 points

                                    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    if (window.location.href.indexOf("franky") > -1) {
      alert("your url contains the name franky");
    }
  });
</script>

4 (10 Votes)
0
3.83
6
Awgiedawgie 440220 points

                                    const isAbsoluteUrl = url => /^[a-z][a-z0-9+.-]*:/.test(url);

// Example
isAbsoluteUrl('https://1loc.dev');          // true
isAbsoluteUrl('https://1loc.dev/foo/bar');  // true
isAbsoluteUrl('1loc.dev');                  // false
isAbsoluteUrl('//1loc.dev'); 

3.83 (6 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
url checker javascript check if url contains specific string javascript javascript test if url exists can url contains % javascript check for url check if url javascript “check if string contains url javascript check url with javascript check if string is a url node.js function check if url contains words function check if url contains string check current url contains in javascript javascript check string in url if something is in url how to check for url string javascrpt how to check for url string js check if an url is working if in url %} JS detect if URL contain´s js if url javascript check to see if a string is a url check if coming from specific url javascript run javascript if url contains javascript if url achor check actual url js javascript is URL check url include js javascript if url is javascript check if url is check if url exist js check if valid url js url contains some string js check string url how to a check a URL in javascript how to check for a valid url in javascript check if syring is in url if current url is then javascript check if text is a url js check if text is a url j js check if url is * javascript function to check valid url function to check url js test url javascript get url check how to check strig has url javascript is url check js check page url js if(url) js check if www in url string? javascript how to check if string is valid url js check if string is valid url js check string is url check if string exist in url how to check string contain url or not if something is a url check if a string is a valid URL how to check what url represents in javascript check a url string contains vaue how to check if url has string javascript check if url has string js Check for URL in a String. check url in js how to know if a string is a url in javascript url check javascript how to check particular string is include in url or not check string if url or not check if url exists in javascript javascript how to know if is a url how to check url javascript if url = js if URL has javascript check if url contains ? symbol javascript check if url includes string check if url contain specific word check if url contains string java check if something is an url javascript url contains string in js check if string is valid in url check if an url contains string url detect using js javascript check if url exists how javascript can check url if you url has then do this js see if url contains string and then set value nodejs find if a string is url if url javascript js check if url has # check uri javascript check if url exists js angular check if url contains string url contains string check check if string is url in javascript how to check if url contains a paramter in javascript check if url is correct javascript javascript check if url contains / javascript check url string how to get if from url in js if current url js check if its uri js javascript check what the url is check string is url js check string is url js check if url contains javascript detect string if url if check url this javascript check if url contain how to check in string is a url in js check page url javascript check if string is url in node js check if a url contails a string js check if a url contails a string js get url of ifr js if url is check if string is url javascript js check if string is uri js check if string is url detect if string is url check location url using js js is string url detect url javascript js check url if it contain string if URL contains one string then how to check in js js check url contains javascript check if something is a url check js url if url page js detect url in string javascript if value is a url js check if valid url js if url contains string verify if an url is an url check if a string is an URL check if a string is valid Url how to check if url exists javascript how to check if url is a valid url by javascript how to check url with js how to check vaild url in js check if string is url js check url if its detail javascript JS CHECK IF IS URL javascript verify url javscript check if string is url how to check if a url is valid in javascript js check url page Checking if a string is a URL determines whether a string represents a valid URL. if ? in url check is url javascript javascript check if the string is url js check valid url how to check the url of a website using javascript how to know the url contains a string check if str is url check if url contains javascript check if strong is url javascript check if string is url js see if string is a url javascript check if valid url javascript check if current url contains string check if is valid url js find if on certain url in js how to check the url of the website in js how to check string for url how to check if text is a url in js? check page url js javascript if string is url how to check if the url contains a given string in javascript check if string in url js check is url check if url has string javascript javascript check if is valid url check if url is valid js test url javascript javascript check if url check if a string is URL how to figure out if a string is url in javascript javascript check if a string is a url js check if text is a valid url check if url exist javascript how to check if something is a valid url javascript string containing url check if string is a url js check if is url javascript check if browser is on certain url js how to check string is valid url js check whether string is url in javascript check if string is url javascript can load the URL checker javascript valide url javascript url is valide check if string is url or not javascript check if string is url or not how to find an string contains url check if url is valid string chek if string is url check a url contains a string js test if valid url javascript check if string is a valid url how to know if string is url how to test if a url contains a string how to detect url in javascript check if something is an url javascript javascript detect string is a url javascript detect URL how to check url string js check if string is a url check url page js check if url how to check string is url in js detect url js javascript check url contai node check if string is url check if a string is a url javascript if url can a url contains - javascript how i can detect my url javascript if current url contains check if url contains string typescript js check if url contains a string js if url contains check if the String is good for url how to check text contains correct url or not check if url contains string javascriptr check the url javascript js detect url in string how to get local url in js how to check url validity javascript if url contains in js javascript is string url check if valid url js javascript function check url if string valid url javascipt if url is check if page is a certain url javascript how to check if a string is a url node how to check if a string is a url javascript detect if is url how to test if string containt url check if url exists javascript how to check the url with js if current url is javascript check if url contains string angular check if url is correct js javascript to check if url contains how to verify current url on js javascript rad url check url for substring javascript how to got to link in javascript jsverify if url have protocols check for web links in string javascript how to detect the current url javascript prompt to url nodejs check if url is from website url show in html js how to know the url of a website in js js check whether its a link? js get sitename of url nsws content check js url validation javascript get url that has a word jquery check if javascript best way to find string in url site:stackoverflow.com javascript best way to find string in url javascript determine if string is valid url jquery if page url contains js indexof string url how to check html is link js how to find the current url in javascript isUrl() in javascript is valid url js check if check url contains string javascript requestd url in js how to detect a spcefic string in url angularjs regex link checker if url contains variable jquery if url contaiuns how to know your current url is url javascript javascript is valid url ? javascript url validat check if string in url javascript url validator javascript detect window locaiton in js monitor the url # javascript js a tag get completee url javascript url validation window.location.href.contains how to capture url from window.location how to check url in string using javascript javascript see if something is a url validate website js window current url javascript not contain check if string contains url javascript check url in string javascript check url for string javascript function get current url check for valid url javascript vanilla javascript find out if href contains https javascript find out if href contains https if url is / jquery find strin in url javascript check if url contains any word from array js check if strning is url index of window.location.href hoq to access the current href check if url contains ? javascript javascript check if url is valid check if a valid link js check if url has string using window js is valid url how to check url in javascript if found in location.href jquery how to validate link in javascript js url validation check if string is url online check if url contains in javascript check the url in javascript how to find current url request.url.indexOf("http") window.location includes string dom current url how to find string is web url or not in javascript es6 check for url retrieve url javascript check if ? is in url get home page in js get current page url how to check given string is website link or not in angular window.location.href containts get # from url javascript get #? +from+url+javascrip is url in js check if url contains get statment js check if url contains ? js lodash is valid url check if url jquery how to know if given url is valid javascript if url contains parameter grab url from dom using get from url javascript add http only before valid url in javascript add http only before valid url in js js if url contains parameter how to get url in if in javascript validate url javascript js check if path contains find if url in string how to check given string is a link or not in angular check current url in javascript get info from website url javascript react how to check if a url is online ge current page javascript verify input is valid url javascript js get current location window how to fetch m persent from the url in javascript js check if url is email address javascript test if link is valid how to check if a string is url in javascript check if it's a url js js deetect url js check ur html input check if proper url chek is url in js javascript path contains code to check if something is a valid url get specific thing from window url in js js if current url contains is url js how to check in javascript if a route has a certain string javascript how to check if url is valid javascript valid url check if string is url or not js how to find the url has ? find string in url javascript js check string in url if url contains string javascript if page url is how to get the link name in javascript js check if string is a url validate url argument js check if current url is javascript validate a url in javascript to check current url js detect current url check if link is valid javascript check if url is valid online javascript check if url is valid javascript how to make sure a url is valid javascript index of url javascript check if url has / nodejs check if text contains a url or media url validation in javascript check string is url javascript function to check if pathname contains struing js how to copy current url using javascript jqery check isValidURL jqery check if url check if current url contains www js check url true check if is valid url javascript check if is valid url how to get url info in html validate url domain name in js react check if text is link js check if url exists javascript find sepific url js check if url is valid js get this url how to check if a string is avalid url in javascript valid url javascript function check for a valid url or hostname js check if string exists in url jquery make a current on a href check string for url js javascript check if page path is in list check if $location.path is loaded jquery search uri for particular word window.location.href include if url has string jquery javascript current url contains validating url in js js isURL JS validate if is url javascript check url contains string js test if variable is url jquery redirect url if url ends with certain value detect is url invalid link validation in js js check is url if url contains string javascript is valid website check in javascript how to javascript current html page jquery check if page url contains validate url in typescript how to check its url or or not in javascript if the url comtains check if url contains inpage link jquery javascript check if url changes typescript validate uri route how to url is not string how to validate url in javascript vanilla js check if url contains jquery url match particular string javascript check if in url make condition if # value is available in url jquery check if a string is a url javascript how to check url with javacript check url contains string in jquery page url endswith javascript js if page url contains check if url contains string angularjs typescript how to tell if the window.location contains a certain character javascript check if string in url javascript find substring in url how to check if input url has http or https python (location.href.indexOf detec if a string is link js check if url in string = true js check if url js validURL check if url contain ? check if url contains question mark how to check url js check if url cotains word javascript check if link is valid node check if url contains node server check if url contains check if string appear in url javascript cenck url contents login check if url has string javascript check if string is valid url javascript js validate url check if args is url js how to check if something is a url url javascript validation regex to check if given text is url javascript check valid url javascript javascript get page via url check link for string javascript link contains string url string problem js javascript code for url javascript check if link contains document javascript check if url is reachable and contains data how to validate whether given link has a valid document or not javascript how to to access the url of the page in in javascript react check if string is url how to look at the page url js how to check if text is link how to check valid url in javascript js string url validate javascript get url /screen js url validadtor jscript extract domain from current location get current page javascript javascript check if page url matches string check if current url contains this string java java check if current url contains this string java java check if current url contain this url javascript validate url how to keep checking if text is in url if url contains html check if string is a url react native check if string is a url react check current page html location href indexOf javascript validate https url javascript check if string contains url js check if string is utl how to validate url in javascript Check if a JavaScript string is a URL how to check the current page in js if url includes a .net then javascript if url includes a .net then javascript html get url check if link is the current page javqscript javascript check url for string get exact url of web page javascript get request url from browser window find string in url using jquery js check if current url contains check string in link jquery how to reterive the url using Javascript how to see if a link contains substring javascript how to get url of same page in javascript javascript if location.href contains javscript check if url exists in string if href contains javascript current link js know website url in javascript get in url javascript get # in url javascript how to say if window.location == something then it does something in javascript get current url with javascript and show button how to check if url contains https javascript href contein javascript current site url in javascript if(window.location.href == contains string check if the url has id window.location.includes check if url contains parameter javascript javascript how to check current url find url from body js js get # from url how to load url in window object JS check url contains js print url in javascript check if url contains a string javascript check if a url has a specific path javascript javascript url find contains slug javascript check if match url contains how get My curent url read REQUEST URL in javascript read request url in javascript js if came from url contains window.location.href.contains is not a function url get js how to check if url has specific string javascript get current page in javascript {% if page.url contains 'tome-xi' %} html if url contains check if domain contains string javascript url contains word js check url for specific string javascript how to check if link contains certain text if window.location cpnsist of in javascript check if url contains string react if url contains jquery a hef url contains jquery if url contain jqury check if url contains jquery how to get location of page js if windows href contain include string in url if page url is x javasc javascript js href location current how to check href has a particular text javascript check the current url javascript javascript check if window location href contains document location current page get actual page js get full url javascript with # window.location.href contains a string js check part of url mathes javascript get url after ? javascript capture cureent url in javascript jquery check url contains some word jquery check url contains jquery check if url contains a word jquery url contains word how to see if a URL search contains taggs jquery if url contain check contains in url in jquery javascript check url contain specific attribute nodejs check if url contains how to capture the web url using javascript javascript href contains react if url contains do fgetting orm url js get from url fetch url of html page javascript jquery location contains how to select current url with javascript window.location.href.contain js url get js get url final page jquery current url contains jquery current url container window object in javascript take url check rul js window.location.href contains use window to get the current location if url contain this paramater HOW TO SEE window url javascript get the url and find string include how to get web page using javascript how to get web page using javas how to get web page using js if url contains javascript get actual page url js js detect url js detect url on load how to get the actual link get page url in html how to check for ? in in url javascript get page url check if url has number javascript window.location.href.includes how to get url property from window in javascript location.href.includes url.includes check the url has a specific property javascript javascript check if current page match array href javascript href indexof verify current url javascript url contains check javascript url.contains how to get url info in javascript window.location.href.indexof( how to check exist char ? in url link in jquery get data from current url javascript get url string javascript jquery if url contains word if url contains string js get current url in js window.location.href.indexof know if a string is contained in the url asp.net check if last part of url contains javascript test current url how to check url contains string in javascript js read url jquery if window.location.href contains how to get adddres of a website in javascript url contains javascript get web url js contains url javascript jquery string contains window location check if url contains $& how to check the url js url in javascript get current href javascript if url contans string js how to check if url contains part of string fetch the current url site url in javascript how to get url of the page in javascript if url contain check url js jquery if url has parameter if url contains location url using js javascript url page check url in html check url html get current url of page javascript window.location.href get current url how to check if windows.location.href contains a path jQuery if url has string javascript get document url how to get url in javascript in php javascript check ur javascript get current href javascript condition URL contains javascript check current page path contains how to get link of page in javascript js get url how to get url js current window url in js javascript check window url jquery if url contains id how to use current url in href html get current page url html get the current url js how to fetch url in javascript give website url js jquery if url contains current url in javascript javascript code to get the current route get website link js get link js javascript find if you are in specific url get current url object in javascript get full url javascript js check what url js check for url jquery check url contain check current url javascript get current url path in js how to get current url html get address js get url information in javascript js how to check the location of a string javascript url contains check URl has content react how to find url locator using javascript grab current url javascript js check if URL typed js check url in string check if url contains string js if url contains js javascript current path get url of page javascript javascript get current html url getting the url in javascript how to check the page url in js get location of the page with js in javascript how to get the website url javascript javascript to get current url check url has certain word javascript can url string contain _ javascript to get current page url javascript get current url get host in js html getting currentpage url how to get the current url in javascript get the current request path in java javascript get browser url in javascript how to get current link in html vanilla javscript get current url path how to check the url in javascript jquery if (window.location.pathname.indexOf run ajax jquery if location.pathname contains run ajax else if how to get current url js get window url javascript obtaining complete url javascript how to get url in javascript of current page js url includes detect if url contaions js display active url with js get current url value in javascript get host url javascript javascript check if url contains how to check if a link contrains a keyword js find url js how to get the current url js how to check if the url of a page is something in js jquery if current url contains url includes javascript how to get the current webpage in javascript check if url has a certain string get current url in javascript how to get current url in javascript react js check if url contains a value jquery check if url contains parameter check if tul has string search for string in url javascript how to get the current HTML adress javascript location.href current page get page url javascript main get page url javascript how to get the link of my current page js react check if pathname includes part of url if url includes string javascript get url javascript getting current url in javascript js get ur javascript get all local href javascript check if on substring in url get current url js javascript current path url jquery check current url contains check if a url contains a string get full path from url javascript how to get the present url in js js check if url contains string javascript check page url read current url in javascript javascript current url javascript get url request a url javascript window.location.href.indexof contains string javascript window.location.href.indexof check url in javascript get page url in javascript get url of current page javascript how to check if url has .html present javascript check if the url contains how to get the address of current page js get current url javascript how to get current url in html check the url in js if string in window location href get page location js on click get full url of current page javascript get full url of current page javascript js get current url js check url javascript check if url has path javascript find string in url find starting keyword in url using javascript get page javascript check if a string exists in url jquery how to read the url in javascript js check that url contain get current url using javascript how to check if url contains string html get current url get url in javascript window location href contains string getting the current location of url js if link contains word react to check if the string in present in url if url contains string jquery how to get browser url in javascript javascript get full url how to get url in js get url of current website javascript get current url of website javascript get the current url using javascript how to get url of site in javascript javascript item url where url includes string how to get the url of a page in javascript javascript if url contains how to identify if a particular name exists in the url javascript .search of string in url js check if url has certain string javascript chaeck the url js js check url then run function react if url contains check if url contains get parameter js find string in url check if url matches javascript check if url matches check if url contains string javascript javascript check if url equals string js url contains javascript url check url contains ? javascirpt check if string exists in url in js check url and if contaicns string then do this javascript if window.location.href contains window.location href includes id javascript check url vue router check if url contains a certain word js check if word is a urrl js check if word is a link how to check link contains https in javascript check url javascript check if something is a url in html get the url in jquery and if url contains get link contains string javascript check url contains javascript how to get particular word from url in html jquery check if url contains string js if path contains text javascript check if url contains string check if url contains string
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source