2 Replies Latest reply on Dec 17, 2007 7:07 AM by orlando_ribas

    Search box problem - Capital letters

    orlando_ribas Level 1
      Hi there,

      I have a little search box, wich is used to go to somewhere else just when you type the word "albergaria".
      But when you put "ALBERGARIA" or "Albergaria" with capital letters, the movie don't work.
      This is my code:

      var senderLoad:LoadVars = new LoadVars();

      sender.onRelease = function() {
      if ((pesquisa.text == "Albergaria")) {
      } else {

      Can someone help me please? I'm just a poor begginer... :)
        • 1. Re: Search box problem - Capital letters
          Level 7

          > if ((pesquisa.text == "Albergaria")) {

          This condition of your if() statement is what does it. It compares the
          contents of pesquisa.text to a literal string, "Albergaria" -- and that
          string begins with a capital letter, with lowercase letters afterward.
          Instead, it sounds like you want to check for the string "Albergaria"
          without regard to case (doesn't matter where the capitals are), so you could
          do something like this:

          if ((pesquisa.text.toLowerCase() == "albergaria")) {

          The reason that works is because the value of pesquisa.text is a string,
          and the String class features a toLowerCase() method. In this context, it
          doesn't matter what the user types. Might be albergaria, might be
          Albergaria or aLbErGaRiA or any other combination. Doesn't matter. The
          toLowerCase() method temporarily converts that value to lower case --
          "albergaria" -- and compares that against the literal string "albergaria";
          if they match, all is well; if they don't, your else is performed.

          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."

          • 2. Re: Search box problem - Capital letters
            orlando_ribas Level 1
            It works, many thanks David.