title: Backspace (deleting characters) not working properly in Firefox due to Javascript
body: <p>I am writing some Javascript/Jquery for a co-worker that is supposed to edit text in a textfield as the user is typing. The purpose of the code is to add formatting to a string of characters (in particular, formatting strings of twelve characters into a valid formatted mac address), however on Firefox I am unable to use the backspace to delete characters once they have been entered into the textfield. </p>
  
  <p>Here is the code that does the formatting:</p>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function () {
      var length = 0;
      $("#mac_input").focusin(function (evt) {
  
          $(this).keypress(function () {
              content = $(this).val();
              content_pre_format = content.replace(/\:/g, '');
              content_formatted = content_pre_format.replace(/\n/g, '');
  
              var text_input = $('#mac_input');
  
              if (content_formatted.length % 12 == 0 &amp;&amp; length != 0) {
                  text_input.val(text_input.val() + "\n");
              }
  
              length = content_formatted.length % 12;
  
              if (length % 2 == 0 &amp;&amp; length != 0) {
                  if (text_input.val().charAt(text_input.val().length - 1) == ':') {
  
                  } else {
                      text_input.val(text_input.val() + ':');
                  }
              }
  
          });
      });
  });
  </code></pre>
  
  <p><strong>Edit:</strong> I figured out more about the bug. When I start typing, lets say "abc", right when I type the "c" the script edits the field to show "ab:c". I can backspace the "c" and the ":" but no more. At this point the text field shows "ab", however if I use ctrl-a to select all, the text field changes to "ab:" </p>