title: How to force loop to wait until user press submit button?
body: <p>I have simple function which checks if entered pin code is valid. But i don't know how to force for-loop to wait until i enter code again to check again it's validity.<br/>
  So how it should be - i type PIN code, then <strong>click OK button</strong> and it checks whether it's correct (if it is, i can see my account menu; if it's not i have to type it again and i have 2 chances left). My code fails, because PIN when code is wrong program should wait until i type new code and <strong>press OK button again</strong>.<br/>
  I tried setTimeout(), callback(), but it doesn't work. This is what i have - a function with for-loop that just runs 3 times (as it is suppose to, but not instantly) without giving a chance to correct the PIN code.</p>
  
  <p>That's whole, unfinished yet, code: <a href="http://jsfiddle.net/j1yz0zuj/" rel="nofollow">http://jsfiddle.net/j1yz0zuj/</a></p>
  
  <p>Only function with for-loop, which checks validity of PIN code:</p>
  
  <pre><code>var submitKey = function(callback)
  {
      console.log("digit status" + digitStatus);
      if (digitStatus == 0)
      {
          correctPIN = 1234;
          var onScreen = document.getElementById("screen");
          for (i=0; i&lt;3; i++)
          {
              if (onScreen.innerHTML.slice(15, onScreen.innerHTML.length) == correctPIN)
              {
                 setTimeout(accountMenu, 1250);
                 //break;
              }
              else
              {
                  onScreen.innerHTML += "&lt;br&gt; Błędny kod PIN! Wpisz PIN ponownie. &lt;br&gt; Pozostało prób: " + (2-i);
                  callback();
                  //cardInserted = function(function(){console.log("Ponowne wpisanie PINu");});
              }
              if (i=2) console.log("blokada");
          }
      }
      else if (digitStatus == 1)
      {
  
      }
  
  
  }
  </code></pre>