It's hard to say exactly what is happening with your code without seeing the rest of it, but I'm sure that adding the event.preventDefault()
line will solve your problem. It basically stops the browser from carring out the default action for the event see example http://jsfiddle.net/3m4eL/
$('input[type="text"]').keydown(function (event) {
if (event.keyCode == 13) {
$("input").eq($("input").index(this) + 1).focus();
event.preventDefault();
}
});
Note that I've only bound the function to the keydown event of the text inputs, and not the submit input - otherwise you can't submit the form at all
note that event.preventDefault()
does not exist natively in Internet Explorer prior to version 9, but jQuery adds the missing function for you and uses event.returnValue = false
as a fallback