title: Textbox Validation on length of the digit
body: <p>Following is my view page,</p>
  
  <pre><code>&lt;table class="width_full cellspace" border="0" cellspacing="0" cellpadding="0" style="vertical-align:top"&gt;
      &lt;tr&gt;
          &lt;td colspan="3"&gt;
              &lt;strong&gt;@Html.Label(Model.objTRSkillGradeLabelEntities.lblBPBlockedfor)&lt;/strong&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr style="font:11px/20px Arial, Helvetica, sans-serif"&gt;
          &lt;td style="width: 33%;"&gt;
              AccountId
              &lt;span class="redFont"&gt;*&lt;/span&gt; :
              &lt;input type="text" id="txtBlkAccountId" /&gt;
              &lt;label id="lblAccountId" class="error"&gt; &lt;/label&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td colspan="3" class="textCenter"&gt;
              &lt;input class="btnInput" type="submit" value=@Model.objTRSkillGradeLabelEntities.btnBPSubmit onclick="javascript:UpdateTRData();" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>function UpdateTRData() {  
      var errorflag;
      document.getElementById('lblAccountId').innerText = "";
  
      var BlkAccountIdV = $('#txtBlkAccountId').val();
      if (BlkAccountIdV == "" || BlkAccountIdV == null) {            
          document.getElementById('lblAccountId').innerText = "Enter AccountID";
          errorflag=1;
      } 
  
      var txtLength = $("#txtBlkAccountId").val().length;
      if (txtLength != 7) {
          document.getElementById('lblAccountId').innerText = "Enter valid AccountID";
          errorflag = 1;
      }
  
      var i;
      s = txtLength.toString();
      for (i = 0; i &lt; s.length; i++) {
          var c = s.charAt(i);
          if (isNaN(c)) {
              document.getElementById('lblAccountId').innerText = "Enter valid AccountID";
              errorflag = 1;
          }
      }
  
      if (errorflag == 1) {
          return false;
      }
  
      var AssociateID = $('#lblAssoID').text();       
      var BlkAccountId = $('#txtBlkAccountId').val();
  
      $.ajax({                      
          url:"@Url.Action("UpdateBlockDetails", "TravelReady")",             
          data:{            
              strAssociateID: AssociateID,           
              strBlkAccountId: BlkAccountId
          },
          dataType: "json",
          type: "POST",
          error: function(e) {
              alert(e.getException().getMessage());
              alert("An error occurred.");
          },
          success: function(data) { return data; }
      });
  }
  </code></pre>
  
  <p>I've Validated the Account Id textbox to Accept Only 7 digits. This Validation will work after clicking the button. I need to give one more validation like, could not Enter More than 20 Numbers. That is if I enter 21st digit alert box should display. How can I perform this validation using jQuery?</p>