how to prevent any key long pressing jquery -


i trying restrict inputs user.like user should not press key continuously..it can take maximum 4

exmp:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa want restrict this.now textbox should not take input after 4 aaaa..like same letters.

below code you

$(document).ready(function(){    var flag=0;    $("#txt").on('keydown',function(e){       flag++;      if(flag>4){                                             e.preventdefault();      }    });    $("#txt").on('keyup',function(e){           flag=0;                });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  <input type="text" id="txt">


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -