jquery - Restricting tabbing through input field using JavaScript key code 9 -
i'm trying prevent user using tab key tab through input boxes on form following code
$(document).ready(function(){ $(":input").on("keydown", notab); }); function notab(evt){ $(this).keypress(function(e){ if(e.keycode == 9) e.preventdefault(); }) } but not working still able use tab key tab through input fields. have similar function restricting user using spacebar, work.
$(document).ready(function(){ $(":input").on("keydown", nospace); }); function nospace(evt){ // prevent user entering space $(this).keypress(function(e){ if(e.keycode == 32) e.preventdefault(); }); } where did go wrong?
edit: i'm using uikit front end html
you can set tabindex -1 prevent tabbing <input> field:
<input type="text" tabindex="-1"> if must use javascript/jquery change tabindex property after page loads:
$(':input').prop('tabindex', -1); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <input type="text"> <input type="text"> <input type="text">
Comments
Post a Comment