
批改狀態(tài):合格
老師批語:完成的很好,只是在提交的時候要在狀態(tài)那一欄選擇作業(yè)進(jìn)行提交
類型 | 描述 | 示例 |
---|---|---|
text | 文本框 | <input type="text"> |
password | 暗文文本框 | <input type="password"> |
有驗證的郵箱表單 | <input type="email"> |
|
number | 數(shù)字文本框,只能輸入數(shù)字 | <input type="number"> |
date | 年月日的數(shù)字滾輪 | <input type="date"> |
radio | 單選框 | <input type="radio"> |
checkbox | 復(fù)選框 | <input type="checkbox"> |
image | 圖形化 submit 按鈕 | <input type="image"> |
select
元素用來創(chuàng)建下拉列表</select>
<select>
元素中的 <option>
標(biāo)簽定義了列表中的可用選項。
示例
<div>
<select>
<option value="0" required disabled>--請選擇--</option>
<option value="1">唱</option>
<option value="2">跳</option>
<option value="3">Rap</option>
<option value="4" selected>籃球</option>
</select>
</div>
類型 | 描述 | 示例 |
---|---|---|
name | 控件名稱,作為鍵值對的一部分與表單一同提交 | name="password" |
value | 控件的初始值 | value="18" |
max | 最大值 | max="2023-03-13" |
min | 最小值 | min="1997-05-08" |
maxlength | value的最小長度(字符數(shù)) | maxlength="18" |
minlength | value的最小長度(字符數(shù)) | minlength="18" |
size | 控件的尺寸 | size="18" |
selected | 預(yù)先選定該選項。 | selected |
placeholder | 出現(xiàn)在控件上的文字 | placeholder="請?zhí)顚懹脩裘? |
chenked | 控件是否選中 | chenked |
required | 布爾值。如果存在,這個值是必需的 | required |
disabled | 布爾值。表單控件是否禁用 | disabled |
radio
單選按鈕允許在多個擁有相同 name
值的選項中選中其中一個。
<div>
<label for="sex">性別:
<input type="radio" name="gender" value="sex" id="sex" />男
<input type="radio" name="gender" value="sex" id="sex" />女
<input type="radio" checked name="secrecy" value="sex" id="sex" />保密
</label>
</div>
checkbox
復(fù)選框需要返回多個值,需要在name屬性中加[]。
<!-- 復(fù)選框 -->
<div>
<label for="hobby">愛好:</label>
<label for="hobby"><input type="checkbox" value="hobby" name="hobby[]" id="hobby"/>唱</label>
<label for="hobby"><input type="checkbox" value="hobby" name="hobby[]" id="hobby"/>跳</label>
<label for="hobby"><input type="checkbox" value="hobby" name="hobby[]" id="hobby"/>Rap</label>
<label for="hobby"><input checked type="checkbox" value="hobby" name="hobby[]" id="hobby"/>籃球</label>
</div>
<!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=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<form action="0313.php" method="post">
<fieldset>
<legend style="text-align: center">用戶注冊</legend>
<input type="text">
<!-- 文本框 -->
<div>
<label for="usname">賬戶:
<input type="text" placeholder="不少于6位數(shù)" name="usname" id="usname" maxlength="12"/></label>
</div>
<!-- 暗文文本框 -->
<div>
<label for="password">密碼:
<input type="password" placeholder="輸入密碼" name="password" id="password" minlength="8"/></label>
</div>
<!-- 郵箱表單 -->
<div>
<label for="email">郵箱:
<input type="email" placeholder="注意郵箱格式@" name="email" id="email"/></label>
</div>
<!-- 數(shù)字 -->
<div>
<label for="age">年齡:
<input type="number" name="age" id="age" value="18" min="18" max="20">
</label>
</div>
<!-- 日期 -->
<div>
<label for="birthday">
<input type="date" name="birthday" id="birthday" value="1997-05-08" min="1997-05-08" max="2023-03-13">
</label>
</div>
<!-- 單選框 -->
<!-- check = "chcked"表示默認(rèn)選擇,應(yīng)用于單選和復(fù)選 -->
<!-- name需統(tǒng)一才可以單選,唯一選項-->
<div>
<label for="sex">性別:
<input type="radio" name="gender" value="sex" id="sex" />男
<input type="radio" name="gender" value="sex" id="sex" />女
<input type="radio" checked name="secrecy" value="sex" id="sex" />保密
</label>
</div>
<!-- 復(fù)選框 -->
<div>
<label for="hobby">愛好:</label>
<label for="hobby"><input type="checkbox" value="hobby" name="hobby[]" id="hobby"/>唱</label>
<label for="hobby"><input type="checkbox" value="hobby" name="hobby[]" id="hobby"/>跳</label>
<label for="hobby"><input type="checkbox" value="hobby" name="hobby[]" id="hobby"/>Rap</label>
<label for="hobby"><input checked type="checkbox" value="hobby" name="hobby[]" id="hobby"/>籃球</label>
</div>
<!-- 下拉框 -->
<div>
<select>
<option value="0" required disabled>--請選擇--</option>
<option value="1">唱</option>
<option value="2">跳</option>
<option value="3">Rap</option>
<option value="4" selected>籃球</option>
</select>
</div>
<!-- 多行文本框 -->
<div>
<label for="">個人簡介:
<br>
<textarea name="" id="" cols="30" rows="7" placeholder="老師好,我是練習(xí)時長兩年半的個人練習(xí)生ikun。喜歡唱、跳、rap、籃球。"></textarea>
</label>
</div>
<!-- 圖片 -->
<div>
<label for="picture">
<input type="image" src="./0313image/1.png" alt="同意" width="220px" id="picture" onclick="alert('密碼輸入正確')">
</label>
</div>
<div>
<button>提交</button>
<input type="reset" value="重置">
</div>
</fieldset>
</form>
</body>
</html>
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號