<script language="javascript" type="text/javascript"> var b4 = ""; function isChar(c) { return "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".indexOf(c) != -1; } function kp_Id(evt) { var isIE = (navigator.appName == "Microsoft Internet Explorer"); var isSafari = (navigator.userAgent.indexOf("Safari") != -1); var evt = (evt) ? evt : ((event) ? event : null); var charCode = (evt.charCode || evt.charCode == 0) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : evt.which); var c = String.fromCharCode(charCode).toUpperCase(); if (isChar(c)) { if (isIE) { evt.keyCode = c.charCodeAt(0); evt.returnValue = true; } return true; } else { if (c.length > 0 && charCode > 0) { if (isSafari) { return false; } if (evt.returnValue) { evt.returnValue = false; } else if (evt.preventDefault) { evt.preventDefault(); } else { if (evt.keyCode) { evt.keyCode = 0; } return false; } } } } function kd_Id(evt) { var evt = (evt) ? evt : ((event) ? event : null); var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); b4 = elem.value; } function ku_Id(evt) { var evt = (evt) ? evt : ((event) ? event : null); var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); var frmSignup = document.getElementById("frmSignup"); var charCode = (evt.charCode || evt.charCode == 0) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : evt.which); var c = String.fromCharCode(charCode).toUpperCase(); if (elem.value.length == 4) { if (elem.value.substr(0,3) == b4) { var nextElement = null; switch (elem.name) { case "txtID1": nextElement = document.getElementById("txtID2"); break; case "txtID2": nextElement = document.getElementById("txtID3"); break; case "txtID3": nextElement = document.getElementById("txtID4"); break; } if (nextElement != null) { nextElement.focus(); } } } } </script> <body onload="try { document.getElementById("txtID1").focus(); document.getElementById("txtID1").select(); } catch(e) {}"> <table cellpadding="0" cellspacing="0" border="0"><tr><td><input type="text" id="txtID1" name="txtID1" size="4" maxlength="4" onkeypress="kp_Id(event)" onkeyup="ku_Id(event)" onkeydown="kd_Id(event)"></td><td width="15" align="center">-</td><td><input type="text" id="txtID2" name="txtID2" size="4" maxlength="4" onkeypress="kp_Id(event)" onkeyup="ku_Id(event)" onkeydown="kd_Id(event)"></td><td width="15" align="center">-</td><td><input type="text" id="txtID3" name="txtID3" size="4" maxlength="4" onkeypress="kp_Id(event)" onkeyup="ku_Id(event)" onkeydown="kd_Id(event)"></td><td width="15" align="center">-</td><td><input type="text" id="txtID4" name="txtID4" size="4" maxlength="4" onkeypress="kp_Id(event)" onkeyup="ku_Id(event)" onkeydown="kd_Id(event)"></td></tr></table> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]