$("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!