开发者

mask and jQuery text box length

I have a jQuery which uses mask function and on keyup event I want to enter 000 when user type 0 otherwise keep user input. But this code breaks when user enters value with 0 like 80, it replaces 0 with 000, so I need to use length function to prevent it, but it seems to break. Here is code:

$(document).ready(function(){
          $('#test').mask("999");
          $('#test').live('keyup', function(event){
                       if ((event.keyCode == 48) || (event.keyCode == 96)){                    $('#test').unmask;
                   var rtest = $('#test').val().length;
                 //  alert(rtest);
                   $('#test').mask("999");
                   if(rtest<=1){
                  $('#test').val("000");
                  }
 开发者_运维知识库              }

       });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜