title: javascript search string for phrase
body: <p>I have a script that I am working on that I am a little lost on.</p>
  
  <p>I grab a user input (using jQuery) and then loop through an array and see if a phrase from the array exists in the user input. If it is found I am popping up an alert box telling them its found. But for some reason its not working.</p>
  
  <p>Code:</p>
  
  <pre><code>submit = false;
  
              for(i in keyphrases_array) {
                  if(english_text.indexOf(keyphrases_array[i]) != -1) {
                      if(trans_text.indexOf(keyphrases_array[i]) != -1) {
                          submit = false;
                      }
                  } else {
                      submit = true;
                  }
              }
  </code></pre>
  
  <p><code>keyphrases_array</code> is a global array that is set in another function.</p>
  
  <p>Example:</p>
  
  <p>If in my array I have the phrase "Hello World" and my script finds Hello World in the <code>english_text</code> variable it then checks the user submitted text (<code>trans_text</code>). If the phrase is not found in <code>trans_text</code> then the script should return false. </p>