html:
<html>
<head>
<script src="test1.js"/>
</head>
<body>
<form action="ActionServlet" method="post">
u:<input type="text" name="usernum" id="num" onkeyup="test()">
<input type="submit" value="提交">
</form>
</body>
<html>
test1.js:
var length=0;
function test(){
var _o=document.getElementById("num");
length++;
if(length==4){
_o.value+=' ';
length=0;
}
}
温馨提示:答案为网友推荐,仅供参考