title: javascript alert is firing continously even after clicking OK
body: <p>I have a <code>textbox</code> where I want a user to add integer numbers and the number of digits should not be less than <code>10</code>. </p>
  
  <p>The issue here is that the <code>alert</code> message is continuously firing even after clicking OK. Please suggest what is wrong with the code. Also suggest if there any other good methods to implement this</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function checkLength(el) {
    if (el.value.length != 10 || el.getAttribute('data-should-alert') === 'false') {
      alert("Minimum 10 numbers are accepted");
      el.setAttribute('data-should-alert', 'false');
      el.focus();
    } else {
      el.setAttribute('data-should-alert', 'true');
    }
  }
  
  function IsNumeric4(e) {
    var keyCode = e.which ? e.which : e.keyCode
    var ret = ((keyCode &gt;= 48 &amp;&amp; keyCode &lt;= 57) || specialKeys.indexOf(keyCode) != -1);
    document.getElementById("error4").style.display = ret ? "none" : "inline";
    return ret;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="form-group"&gt;
    &lt;label for=""&gt;Stores / Sites  Asst. Manager Mob&lt;/label&gt;
    &lt;input type="text" class="form-control" id="txtStoreSiteAsstMangrMob" maxlength="10" onblur="checkLength(this)" onkeypress="return IsNumeric4(event);" ondrop="return false;" onpaste="return false;" /&gt;
    &lt;span id="error4" style="color: Red; display: none"&gt;* Only numbers allowed (0 - 9)&lt;/span&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>