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 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2003
    Location
    Colorado
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need to check for phrase

    When checking this form I need to make sure that either "whitelist_from" or "whitelist_to" is present and only at the beginning. Here is what I have but it is not working. Can any one help?

    thanks


    if (!item.value.match (/whitelist_from/)||(!item.value.match(/whitelist_to/)))
    {
    alert ('"whitelist_from" or "whitelist_to" must be included at the beginning');
    item.focus();
    return false;
    }

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if ( /^whitelist_(?:from|to)/.test( item.value ) )
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New Coder
    Join Date
    Feb 2003
    Location
    Colorado
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the reply beetle

    what is the .test refer to?

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    test() is a method of the global RegExp object, which is exposed to any pattern. If the pattern exists in the test string, then true is returned.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    New Coder
    Join Date
    Feb 2003
    Location
    Colorado
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks beetle
    It works great, I just didn't understand the .test
    thank you


  •  

    Posting Permissions

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