
批改狀態(tài):合格
老師批語(yǔ):總體沒(méi)什么問(wèn)題
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=, initial-scale=1.0">
<title>注冊(cè)表單</title>
</head>
<body>
<form action="register.php" method="post">
<legend>新用戶注冊(cè)</legend>
<fieldset style="display: inline-grid; gap: 1em">
<div class="username">
<label for="uname">用戶名</label>
<input type="text" id="uname" name="uname" value="" placeholder="請(qǐng)輸入用戶名(不少于6位)" required autofocus>
</div>
<div class="email">
<label for="email">郵箱:</label>
<input type="email" name="email" id="email" placeholder="username@email.com">
</div>
<div class="psw">
<label for="psw">密碼:</label>
<input
type="password"
onkeydown="this.nextElementSibling.disabled=false"
name="password"
id="psw"
placeholder="不少于6位"
required>
<button type="button" onclick="showPsw(this, this.form,true)" disabled>查看</button>
</div>
<div class="age">
<label for="age">年齡:</label>
<input type="number" id="age" name="age" min="18">歲
</div>
<div class="birthday">
<label for="birthday">生日:</label>
<input type="date" id="birthday" name="birthday" value="2020-02-22" min="1949-10-01">
</div>
<div class="sex">
<label for="male">性別:</label>
<!-- input.type中的name是提交到服務(wù)器的 -->
<input type="radio" name="sex" value="male" id="male" checked><label for="male">男</label>
<input type="radio" name="sex" value="female" id="female"><label for="female">女</label>
<input type="radio" name="sex" value="secret" id="secret"><label for="secret">保密</label>
</div>
<div class="hobby">
<label for="">愛(ài)好:</label>
<!-- checkbox的name不能相同,返回的是數(shù)組 -->
<input type="checkbox" name="hobby[]" value="trave" id="trave"><label for="trave">旅游</label>
<input type="checkbox" name="hobby[]" value="program" id="program" checked><label for="program">編程</label>
<input type="checkbox" name="hobby[]" value="shoot" id="shoot"><label for="shoot">攝影</label>
<input type="checkbox" name="hobby[]" value="game" id="game" checked><label for="game">游戲</label>
</div>
<div class="edu">
<label for="">學(xué)歷:</label>
<select name="edu" id="">
<option value="1" selected disabled>---請(qǐng)選擇---</option>
<option value="1">中學(xué)</option>
<option value="2">大學(xué)</option>
<option value="3">研究生</option>
</select>
</div>
<button>提交</button>
</fieldset>
</form>
<script>
// 顯示密碼
function showPsw(ele, form){
const psw = form.password
if(psw.type=='password'){
psw.type = 'text'
ele.textContent = '隱藏'
}else if(psw.type =='text'){
psw.type = 'password'
ele.textContent = '顯示'
}else{
return false
}
}
</script>
</body>
</html>
表單入手不難,難在精通,要多用多練,挺期待下節(jié)課的CSS的。
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)