<3 jquery, autotab between fields

Submitted by cjdmax on Tue, 07/19/2011 - 19:22
$("input.ipaddressparts").keypress(function(evt) {
          if (evt.which == '46' || evt.which == '32') {  // dot or space
                  evt.preventDefault();
                  $(this).next().focus().select();
          }
});

This piece of sheer awesomeness will skip to the next input field of a four-input IP address form. The preventDefault() prevents the space or dot from being printed. and the jquery .next command will skip to the next similar input element.

jQuery makes javascript very painless and we love it!