当前位置: 代码迷 >> Web前端 >> 仿照填写序列号
  详细解决方案

仿照填写序列号

热度:324   发布时间:2012-11-25 11:44:31.0
模仿填写序列号
 function autoFocus(objId){
	        var id = "macAddr"+(objId+1);
	        var next = document.getElementById(id);
	        if(document.getElementById("macAddr"+objId).value.length==2 && next!=undefined){
	            next.focus();
	        }
	    }

	   $(document).ready(function(){
	        $(":input[id^='macAddr']").bind('keyup', handleAddr);
	   });

	   function handleAddr(){
           var current = this;
           var currvalue = current.value;
           var reg = /[^\A-Fa-f0-9]|_/ig;
           if(reg.test(currvalue)){
               alert('invalid');
           }
           else{
           	  var index = parseInt(current.id.substring(7)) ;
           	  autoFocus(index);
           }
	    }
  相关解决方案