Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to check if the URL contains any number or empty?

Hi everyone please I need you’re help !!

How could I do something like this:

<script type="text/javascript">
    $(document).ready(function() {
       if (window.location.href.indexOf(" ") > -1) {
         alert("your url index is empty");
       }
    });
</script>

I need to know whene my Url index contain something (ID number) or empty.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This should get the job done:

   if (window.location.href.match(/\d+/g)) {
     alert("your url index is empty");
   }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading