<html>
<head>
<script type="text/javascript">
function a(){
var va=document.getElementById('username').value;
var reg=/^[a-zA-Z]\w{4,11}$/;//正则验证用户
if(reg.test(va)){
return true;
}
else{
return false;
}
}
</script>
</head>
<body>
<form action="#" method="post" οnsubmit="return a()">
用户名:<input type="text" id="username"/><br/>
密码:<input type="password" id="password"/><br/>
<input type="submit" value="提交">
</form>
</body>
</html>
<head>
<script type="text/javascript">
function a(){
var va=document.getElementById('username').value;
var reg=/^[a-zA-Z]\w{4,11}$/;//正则验证用户
if(reg.test(va)){
return true;
}
else{
return false;
}
}
</script>
</head>
<body>
<form action="#" method="post" οnsubmit="return a()">
用户名:<input type="text" id="username"/><br/>
密码:<input type="password" id="password"/><br/>
<input type="submit" value="提交">
</form>
</body>
</html>