var aInput = document.getElementsByTagName("input");var aSpan = document.getElementsByTagName("span")[0];var i = 0;aInput[0].onkeyup = function () {// this.value = this.value.replace(/[^\d]/, "")}aInput[1].onclick = function () { (aInput[0].value == "") ? alert("请输入数字!") : alert(/^\d{2}$/.test(parseInt(aInput[0].value)) ? "√ 是两位数" : "这是" + aInput[0].value.length + "位数"); }</script>
添加回答
举报
0/150
提交
取消