记录一个JQUERY模仿序列号输入
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script language="javascript" src="js/jquery-1.4.1.min.js"></script> <script language="javascript"> function autoFocus(objId){ var id = "macAddr"+(objId+1); var next = document.getElementById(id); if(document.getElementById("macAddr"+objId).value.length>=4 && next!=undefined){ //alert("asdf"); 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; var index = parseInt(current.id.substring(7)) ; autoFocus(index); } </script> </head> <body> <input name="textfield" type="text" id="macAddr1" size="4" maxlength="4" /> - <input name="textfield2" type="text" id="macAddr2" size="4" maxlength="4" /> - <input name="textfield3" type="text" id="macAddr3" size="4" maxlength="4" /> - <input name="textfield4" type="text" id="macAddr4" size="4" maxlength="4" /> </body> </html>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17