注意题目要求的函数名
<!DOCTYPE html>
<html>
<head>
<title>校验</title>
<script type="text/javascript">
function judge(){
var val = document.getElementById('uname').value;
var pos=/^[a-z]+$/i;
if(pos.test(val))
alert('用户名正确');
else
alert('用户名不正确');
}
</script>
</head>
<body>
<form>
<h3>注册</h3>
<label>用户名:<input type="text" id="uname" name="uname" /></label><br><br>
<label>密码:<input type="password" id="pwd" name="pwd" /></label><br><br>
<input type="submit" value="注册" onclick="judge()" />
</form>
</body>
</html>