how do you check for two parameters with jquery

Posted on 2014-11-24
Medium Priority
Last Modified: 2014-11-24

I'm trying to check the url for either "ID_xxxxx" or "CON_ID_xxxxxx"

The "x" is either a five or six figure number

This is what I have so far. Thanks for the help!

<script type="text/javascript">
        $(document).ready(function () {
            if(window.location.href.indexOf("ID" || "CON") > -1)
                 alert("found it");

Open in new window

Question by:smfmetro10
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 57

Expert Comment

ID: 40463040
if(window.location.href.indexOf("ID" || "CON") > -1)


if ((window.location.href.indexOf("ID") > -1) || (window.location.href.indexOf("CON") > -1))
LVL 58

Expert Comment

ID: 40463045
I assume you want the xxxxx part so what's an example url

(or maybe not)

Author Comment

ID: 40463057
Ah - it would either be "ID_12345" or" CON_ID_123456"
LVL 57

Accepted Solution

HainKurt earned 2000 total points
ID: 40463126
here it is if you need XXXXXX:
var url = window.location.href;
if (url.indexOf("ID_")>-1 || url.indexOf("CON_ID_") > -1)
  alert("found it");
  var num = url.replace("CON_ID_","").replace("ID_","");

Open in new window


Author Closing Comment

ID: 40463179

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question