<!DOCTYPE html>
<html>
<head>
<title>15</title>
<script type="text/javascript">
function judge(){
var value = document.getElementById('nn').value;
var tip = document.getElementById('hint');
var pos =/^[0-9]+$/ ;
if(!pos.test(value)){
//alert("输入错误");
tip.innerHTML = "输入错误";
document.getElementById("nn").value="";
document.myform.uname.focus();
}
}
</script>
</head>
<body>
<form name="myform">
输入:<input type="text" id="nn" name="uname" placeholder="只输入数字" onblur="judge()" /><span id="hint" style="color: red" > </span>
</body>
</html>
document.myform.uname.focus()标签定位到本文档,myform表单下的uname元素上