用戶註冊
先寫一個簡單的用戶註冊框架,沒有啥精美的美工。。。
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
//表單驗證
function mySub(){
var userName = document.forms['myForm']['userName'].value;
var pwd = document.forms['myForm']['pwd'].value;
var tel = document.forms['myForm']['tel'].value;
if(userName.length<3 || userName.length>6){
alert("用戶名必須爲3-6位");
return false;
}
if(pwd.length<6){
alert("密碼必須大於6位");
return false;
}
return true;
}
</script>
</head>
<body >
<h1>用戶註冊</h1>
<span>規則:用戶名長度爲3-6個字符</span>
<hr />
<form name="myForm" action="a.html" method="get" onsubmit="return mySub()">
<p>
用戶名:<input name="userName" type="text" />
</p>
<p>
密碼:<input name="pwd" type="password" />
</p>
<p>
電話:<input name="tel" type="text" />
</p>
<p>
<input type="submit" />
</p>
</form>
</body>
</html>