Jack Jack - 4 years ago 101
Javascript Question

Checking a URL in an if/else statement?

I'm trying to check a submitted URL (excluding any additional paths).

The user submitted URL is:

var inputUrl = document.getElementById("inputVal").value;

If the user submits
then I'm trying to create an if/else statement that will determine whether the site is 'stackoverflow.com', regardless of
or any

if (inputUrl == "stackoverflow.com") {
console.log ("stackoverflow");
} else {
console.log("not stackoverflow");

Any help would be greatly appreciated.

Answer Source
   if(inputUrl.toLowerCase().indexOf("stackoverflow.com") > -1) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download