title: ASP.NET required field validator firing on focus in firefox
body: <p>I have 2 asp.net textboxes in an update panel. Both textbox controls have some javascript attached to autotab to the next field and to allow only numeric input. When I enter some data into the first field and press enter, focus shifts to the next field and the requiredfieldvalidator of the second field displays its "* required" error message, even though I've just entered the field. How can I prevent the validator from firing when I first enter the textbox?</p>
  
  <p>I should also mention that both textboxes are in a gridview footer.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>&lt;asp:TextBox ID="add_ISBN" runat="server" Columns="14" MaxLength="17" CssClass="focus" /&gt;
  &lt;asp:TextBox ID="add_Qty" runat="server" Columns="4" MaxLength="4" /&gt;
  &lt;asp:RequiredFieldValidator ID="rfvQty" ControlToValidate="add_Qty" ErrorMessage="* required" ForeColor="Red" Display="Dynamic" EnableClientScript="true" ValidationGroup="Add" runat="server" /&gt;
  </code></pre>
  
  <p>In the codebehind:</p>
  
  <pre><code> add_ISBN.Attributes.Add("onkeydown", "return isbnCheck(event, '" &amp; add_Qty.ClientID &amp; "')") 
  </code></pre>
  
  <p>And the javascript:</p>
  
  <pre><code>function isbnCheck(e, id) {
      e = e || window.event;
      var key = e.which || e.keyCode
  
      if (validIsbnChars.indexOf(parseInt(key, 10)) &gt;= 0) {
          return true;
      } else {
          if (key == 13) {
              var nextfield = document.getElementById(id);
              if (nextfield) nextfield.focus();
              return false;
          }
          if (e.preventDefault) e.preventDefault();
          e.returnValue = false;
          return false;
      }
  }
  </code></pre>
  
  <p>The javascript allows only a valid subset of characters, and if the user presses enter, sets focus to the next field.</p>