Home > front end >  How to check if the URL contains any number or empty?
How to check if the URL contains any number or empty?

Time:07-21

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.

CodePudding user response:

This should get the job done:

   if (window.location.href.match(/\d /g)) {
     alert("your url index is empty");
   }
  • Related