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

    javascript matching problem

    I'm trying to match the word describe, and if it is found give an alert. If it is not found then everything is good. The code below doesn't work, how do I change it to catch only the word describe?
    if (describe == "describe")
    {
    alert ('Do not put "describe" in, this is done automatically');
    document.AddSpamRules_form.describe.focus();
    return false;
    }

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so you mean you have a paragraph or some text in a textbox and want to find out if the word describe appears in it?

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #3
    New Coder
    Join Date
    Feb 2003
    Location
    Colorado
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes, if it is going to be in this paragraph it will be the first word.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if ( /describe/i.test( describe ) )
    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
    beetle, what does the /i.test stand for?
    It works, just wondering. Thank you
    Last edited by mr_evans2u; 06-05-2003 at 11:05 PM.

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    /describe/i

    is a pattern - meaning "Match the word describe, and ignore case"

    regular expression patterns can't be summed up quickly. Visit the links provided by liorean in a sticky at the top of this forum for more info.
    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”


  •  

    Posting Permissions

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