1 Star 0 Fork 0

erido-8/erido

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
form.html 2.16 KB
一键复制 编辑 原始数据 按行查看 历史
erido-8 提交于 2021-10-19 16:55 . 表单
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>表单</title>
<style type="text/css">
.form{
width: 1400px;
height: 600px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.iform{
width: 500px;
height: 600px;
background: lightgray;
box-shadow: white 4px;
flex-direction: column;
align-content: flex-start;
}
</style>
</head>
<body>
<h1 align="center">表单</h1>
<form class="form">
<div class="iform">
<p>用户<input type="text" id="username" placeholder="请输入用户名" />
<input type="button" value="用户名是否重复"/></p>
<!--密码-->
<p>密码<input type="password" placeholder="请输入密码"/></p>
<p>确认密码<input type="password" placeholder="请确认密码"/></p>
<!--日期-->
<p>出生日期<input type="date" placeholder="请输入出生日期"/></p>
<!--单选框-->
<p>性别<input type="radio" name="sex"/>
<input type="radio" name="sex"/></p>
<!--多选框-->
<p>爱好<input type="checkbox" value="run" name="hobby" />跑步
<input type="checkbox" value="bb" name="hobby" />篮球</p>
<!--下拉列表-->
<p>专业
<select>
<option value="pc">计算机</option>
<option value="sw">软件</option>
</select></p>
<!--大文本框-->
<p>
<textarea placeholder="简介" rows="10"></textarea></p>
<!--文件上传-->
<p>头像
<input type="file"value="file" /></p>
<!--按钮-->
<p>
<input type="submit" value="提交" id="btn" />
<input type="reset" value="重置"/>
</p></div>
</form>
</body>
<script>
window.onload =function(){
let oBtn =document.getElementById('btn')
oBtn.onclick=function(){
let oUsername =document.getElementsByName('username')
console.dir(oUsername[0].value)
let oUsernameById = document .getElementById('username')
console.dir(oUsernameById.value)
let oSex document.getElementByname('sex')
oSex.forEach(item=>{
if(item.checked){
let oValue = item.value
if(oValue ==='female'){
console.log('')
}
else if(oValue ==='male'){
console.log('')
}
}
}
)
}
}
</script>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/erido-8/erido.git
git@gitee.com:erido-8/erido.git
erido-8
erido
erido
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385