How to tab Focus of textbox in ASP.NET using JQuery?

Tab Focus of textbox in ASP.NET using JQuery.

Follow below solution:

When user press the Enter key,
the Tab focus of a textbox moves to the next textbox using JQuery in ASP.NET.

Write below code in the Head tag of a webpage:


<script src="Scripts/jquery-1.9.1.js"
type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function ()
{
$('input:text:first').focus();
$('input:text').bind('keydown', function (e)
{
if (e.keyCode == 13)
{
e.preventDefault();
var nextIndex = $('input:text').index(this) + 1;
var maxIndex = $('input:text').length;
if (nextIndex < maxIndex)
{
$('input:text:eq(' + nextIndex + ')').focus();
}
}
});
});
</script>

About the Author

avatar