Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts

    I remember something like: 'john | james | mary'\i.indexOf(compareVar) etc....

    I remember someone posting something like this...
    where we need to compare numerous strings against ONE var...and instead of doing a bunch of if else statements, there was something like:

    \' james | john | mary \'/i.indexOf(comparedVar) != -1

    or something like this...where we want to know if James, or John or mary --- case insensitive is within the var "comparedVar".....????

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
     <!--//
      function validate(input){
       var regEx = /james|john|mary/gi;
        if(input.value.match(regEx)){
           alert('match');
        }
      }
     //-->
    </script>
    </HEAD>
    
    <body>
    <form>
    <input onblur="validate(this)">
    </form>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •