Saturday 18 February 2012

Focus on Next Control in enter key press using Jquery


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

No comments:

Post a Comment