JavaScript数据简单校验设计

**

JavaScript数据简单校验设计-HTML简单获取另一个HTML输入框的内容以及地区的选择获取

资源获取链接:
https://download.csdn.net/download/Tian208/56339522

**
一、目的
综合使用HTML、JavaScript和CSS进行注册页面设计,具体要求如下:
1)注意整个页面的色调和美观
2)使用Frameset+Table布局(div也可)
3)对用户ID和用户名、口令不符合条件及时判断
4)对口令不一致进行及时判断(34的及时判断,要求提示信息必须显示在同一个页面,也就是说显示在当前的行的后面或者上面或者下面)
5)判断Email地址是否合法
6)在“提交”后能在新页面显示所有的输入信息
程序效果:
在这里插入图片描述
在这里插入图片描述二、过程
源码模块:
在这里插入图片描述

1gerenxinxi.css
.ziti{ 
    font-family:黑体;
    font-size: 25px;
    width: 300;
    height: 30px;
    text-align: center;
    border: 3;
    background-color: #ffffff;
    line-height: 28px;

    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    }

.quanju{
    width: 300px;
    height: 600px;
    padding: 20px;

    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -200px;
    margin-top: -280px;

}

.quanju1{
    text-align: center;

}


.text_field {
    width: 180px;
    height: 28px;
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
	background-color: #ffffff;
    
}

#all{
    width: 100%;
    height: 20px;
}
form p > * {
    display: inline-block;
    vertical-align:middle;
}


2denlu.js

.ziti{ 
    font-family:黑体;
    font-size: 25px;
    width: 300;
    height: 30px;
    text-align: center;
    border: 3;
    background-color: #ffffff;
    line-height: 28px;

    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    }

.quanju{
    width: 300px;
    height: 600px;
    padding: 20px;

    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -200px;
    margin-top: -280px;

}

.quanju1{
    text-align: center;

}


.text_field {
    width: 180px;
    height: 28px;
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
	background-color: #ffffff;
    
}

#all{
    width: 100%;
    height: 20px;
}
form p > * {
    display: inline-block;
    vertical-align:middle;
}


Web-实验2-hjt08.html(首页HTML设计)

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>web-实验二</title> 

</head>
<body background="Picture\zuomian1.jpg" style=" 
background-repeat:no-repeat ;
background-size:100% 100%;
background-attachment: fixed;">
<style type="text/css">
.mytable{
width:100%;
height:100%;
margin:0 auto;
}

.left{
width:1180px;
height:550px;
margin:0 auto;
}

.right{
width:600px;
height:550px;
margin:0 auto;
}

</style>
<table class="mytable">
<tr>
<td colspan="3" style="background-color:#600000;font-size:15px;height:40px;text-align:center;color:aliceblue">
  <h1>用户注册</h1>
</td>
</tr>
<tr>
  <td colspan="3" style="font-size:7px;text-align:left" background="Picture\zuomian1.jpg">
  <h1>用户注册界面,请按要求操作</h1>
  </td>

  </tr>
  <tr>
   <td class="left">
    <iframe src="用户注册信息.html" name="iframe_a" class="mytable"></iframe>
   </td>
    <td style="background-color:#600000;font-size:25px;height:480px;width:50px;vertical-align:top"></td>
    
    <td class="right">
      <iframe src="shiping.html" name="iframe_b" class="mytable"></iframe>
</table>

</body>
</html>

用户注册信息.HTMl

<!DOCTYPE html>
<html>
<head> 
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
<title>web-实验二</title> 
</head>
<script language="javascript" src="js/denlu.js" type="text/javascript"  charset="utf-8"></script>
<body background="Picture\zuomian1.jpg" style=" 
background-repeat:no-repeat ;
background-size:100% 100%;
background-attachment: fixed;" onload='getProvince()'>
<style type="text/css">
.mytable{
width:100%;
height:100%;
margin:0 auto;
font-weight: 200;
}

.mytable1{
font-weight:1000;
width:100%;
height:100%;
margin:0 auto;
text-align:center;
background-color:#ffffff;
}

.left{
width:1180px;
height:520px;
margin:0 auto;
}

.right{
width:600px;
height:520px;
margin:0 auto;
}

.hang{
    background-color:#600000;
    font-size:25px;
    width:50px;
    text-align:center;
}
.shuju{
    height:20px;
    font-size:20px;
}
</style>
<div>
<form  action="test.html" method="get">
<table class="mytable" border="3"cellpadding="6" cellspacing="6">
<tr>
<td colspan="1" style="background-color:#7B7B7B;font-size:10px;height:10px;text-align:center;color:aliceblue">
  <h1>注册界面</h1>
</td>
</tr>
<tr class="mytable1" > 
    <td valign="middle" >用 户 ID: <input type="text" placeholder="请输入你的用户ID:8-16位" pattern="\w{8,16}" id="userId"; name="userId" class="shuju"/></td>
    <span id="s_userId" class="error"></span>
    <tr class="mytable1" > 
    <td valign="middle">用 户 名: <input type="text" placeholder="请输入你的姓名" id="name" pattern="\w{0,16}" name="name" class="shuju"/></td>
    <span id="s_name" class="error"></span>
    <tr class="mytable1">


        <tr>
            <td valign="middle" class="mytable1" id="xingbie">性别:
                <input type="radio" name="xingbie" value=""><input type="radio" name="xingbie" value=""></td>
        </tr>

    <tr class="mytable1" > 
    <td valign="middle">密  码: <input type="text" placeholder="请输入你的密码:8-16位" pattern="\w{8,16}" class="shuju" id="password" name="password"></td>
    <span id="s_password" class="error"></span>
    <tr>
        <td valign="middle" class="mytable1" id="xueli">学历:
            <input type="radio" name="xueli" value="专科">专科
            <input type="radio" name="xueli" value="本科">本科
            <input type="radio" name="xueli" value="硕士">硕士
            <input type="radio" name="xueli" value="研究生">研究生
            <input type="radio" name="xueli" value="博士">博士
    
        </td>
    </tr>
    <tr class="mytable1" > 
        <td valign="middle">生    日:  <input type="date" placeholder="请输入你的生日:xxxx-xx-xx" id="birthday" name="birthday" class="shuju"/></td>


        <tr class="mytable1">
            <td valign="middle"><label for="email">E-mail:</label>
           
                <input type="email" name="email" id="email" placeholder="请输入邮箱"  class="shuju">
                <span id="s_email" class="error"></span>
            </td>

            
 <tr class="mytable1">
            <td>地区:</td>
    <tr class="mytable1"><td>
                <select id="province" onchange="chooseProvince(this)">
                    <option value="1">请选择省</option>
                </select>
                <select id="city" onchange="chooseCity(this)">
                    <option value="2">请选择市</option>
                </select>
                <select id="area">
                    <option value="3">请选择区</option>
                </select>
            </td>
            </tr>

    <tr class="mytable1" > 
         <td valign="middle">地   址:  <input type="text" placeholder="请输入你的地址" id="address" name="address" class="shuju"/></td>
 <tr class="mytable1" > 
     <td  valign="middle">手机号码:  <input type="text" placeholder="请输入你的手机号码:11位" pattern="\w{11}" id="Tel" name="Tel" class="shuju"/></td>
     <span id="s_Tel" class="error"></span>
     <tr class="mytable1">
        <td id="td_reset"><input type="reset" id="btn_reset" value="重置" >
            <input type="button" id="btn_sub1" value="确认信息" onclick="page()">
		<input type="submit" id="btn_sub" value="提交" onclick="page()">
       </td>

</table>
</form>
</div>
</body>
</html>

information.html(在“提交”后能在新页面显示所有的输入信息)

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>个人资料</title>
		<link rel="stylesheet" href="css/gerenxinxi.css">
	</head>
	<script language="javascript" src="js/denlu.js" type="text/javascript"  charset="utf-8"></script>
	<body>
		<style type="text/css">
		
		</style>
<div id="all">

	<div class="quanju" align="center">
		<form>
		       
		            <p><label class="ziti">用户ID:</label><input type="text" id="userId" class="text_field"/></p>
		            <p><label class="ziti">用户名:</label><input type="text" id="name" class="text_field"/></p>
                    <p><label class="ziti">性别:    .</label><input type="text" id="xingbie" class="text_field"/></p>
					<p><label class="ziti">密码:    .</label><input type="text" id="password" class="text_field"/></p> 
					<p><label class="ziti">生日:    .</label><input type="text" id="birthday" class="text_field"/></p>
					<p><label class="ziti">学历:    .</label><input type="text" id="xueli" class="text_field"/></p>
		            <p><label class="ziti">地区:    .</label><input type="text" id="area1" class="text_field"/></p>
					<p><label class="ziti">E-mail:  </label><input type="text" id="email" class="text_field"/></p>
					<p><label class="ziti">地址:    .</label><input type="text" id="address" class="text_field"/></p>
		            <p><label class="ziti">手机号: </label><input type="text" id="Tel" class="text_field"/></p>
					<div class="quanju1">
					<a><input valign="middle" type="button" value="返回" onClick="onClick1()"></a><br>
				</div>
			</form>
			</div>
		</div>
		<table>
			<tr>
				<td>
					
				</td>
			</tr>
		</table>
		<script type="text/javascript">

			document.getElementById("userId").value  =window.localStorage.getItem("userId");
			document.getElementById("name").value    =window.localStorage.getItem("name");
			document.getElementById("password").value=window.localStorage.getItem("password");
			document.getElementById("birthday").value=window.localStorage.getItem("birthday");
			document.getElementById("xueli").value   =window.localStorage.getItem("xueli");
            document.getElementById("xingbie").value =window.localStorage.getItem("xingbie");
			document.getElementById("area1").value   =window.localStorage.getItem("area1");
			document.getElementById("email").value   =window.localStorage.getItem("email");
			document.getElementById("address").value =window.localStorage.getItem("address");
			document.getElementById("Tel").value     =window.localStorage.getItem("Tel");
			
	</script>
	</body>
</html>

提交成功页面设计test.html

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title></title>

    </head>
    <script language="javascript" src="js/denlu.js" type="text/javascript"  charset="utf-8"></script>
    <style> 
      body{text-align:center}      
      </style>
    <script type="text/javascript">
        function onClick(){
 
            window.location.href="用户注册信息.html";
        
    }
    
    </script>
<body>
	<form>
  <table>
	<tr>
		<br><br><br><br>
		<td valign="middle"><input type="button" id=in value="已提交" onclick="onClick()" 
		style="background-color:#7B7B7B;font-size:35px;width:400px;height:80px;text-align:center;color:aliceblue">
	  </td>
	  </tr>
	  <tr>
		  <td>
	  <input type="button" id=in value="返回" onclick="onClick()" 
	  style="background-color:#7B7B7B;font-size:35px;width:400px;height:80px;text-align:center;color:aliceblue">
	</td>
</table>
</form>

    
  
</body>

</html> 

查看个人信息按钮设计shiping.html

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title></title>

    </head>
    <script language="javascript" src="js/denlu.js" type="text/javascript"  charset="utf-8"></script>
    <style> 
      body{text-align:center}      
      </style>
    <script type="text/javascript">
        function onClick(){
 
            window.location.href="用户注册信息.html";
        
    }
    
    </script>
<body>
	<form>
  <table>
	<tr>
		<br><br><br><br>
		<td valign="middle"><input type="button" id=in value="已提交" onclick="onClick()" 
		style="background-color:#7B7B7B;font-size:35px;width:400px;height:80px;text-align:center;color:aliceblue">
	  </td>
	  </tr>
	  <tr>
		  <td>
	  <input type="button" id=in value="返回" onclick="onClick()" 
	  style="background-color:#7B7B7B;font-size:35px;width:400px;height:80px;text-align:center;color:aliceblue">
	</td>
</table>
</form>

    
  
</body>

</html> 

三、实验总结
此文章用来当做学习实验笔记,许多知识未知,不够好的地方可多多指教,如果需要,可以随便使用,谢谢大家!

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

锐行织梦者

谢谢您的支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值