JavaScript 第八天
1.1 表单验证思路
层级搭建
1 搭建一个表单 提示span全部是隐藏的
2 用户输入状态的时候(得到焦点) 只有提示的span显示
3 用书停止输入的时候(失去焦点)
A 如果什么都没有输入 恢复到原始状态
B 如果输入了并且输入错误 只有错误的span显示
C 如果输入了并且输入正确 只有正确的span显示
4 无论之前显示错误提示还是正确提示 再次输入 都只显示提示span
1.2 表单页面的搭建
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<style type="text/css">
fieldset {
width: 500px;
margin: 200px auto;
padding: 30px;
background-color: white;
border-radius: 10px;
}
body,html{
height: 93%;
}
body{
background: url(https: