html+JavaScript登陆注册界面

最近刚刚学习了一些关于JavaScript的知识,便在之前学习的html前端的基础上

做了一些简单的修改,本身还存在着很多的缺陷,希望大家多多指正。

githu下载地址:https://github.com/pengxiang1998/login

[登陆界面2在线预览]:https://pengxiang1998.github.io/login/index/denglu.html
[注册界面在线预览]:https://pengxiang1998.github.io/login/index/zhuce.html

<title>登录</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript">
        function val(){
            var name=window.document.getElementById("user").value;
            var password=window.document.getElementById("password").value;//获取值
            if (name == ""||password ==""){
                window.alert("用户名或密码不能为空!");
                return false;
            }
        
             if(name!="12345678"||password!="12345678"){//判断用户名密码登录
                window.alert("用户名或密码错误!");
                return false;
            }
            return true;
        }
    </script>
    <style type="text/css">
a{text-decoration:none}
</style>
</head>
<body >
<table border=0 ><tr><th width=2000 height=150 border=1 bgcolor='ccffff'><center><table><th><img src="images/30.jpg" width='100' height='100'></th>
<th><font size='7' color='ff7517'>图书用户管理系统</th></table></center></th><tr>
<table style="background-image:url(images/.jpg);background-size: 100%; opacity: 1; filter: alpha(opacity = 30)"><th >
<table border=0><tr><th width=1500 height=600 border=1><img src="images/4.jpg" height='400' width=400></th><th>
<form action="form.html" method="post" onsubmit="return val()" target="_blank">
<table border=0 bgcolor=F0F0F0>
<tr><th width=12 height=45></th><th colspan=3 width=82 height=45 align='left'>账户登录</th></tr>
<tr><th width=12 height=20></th><th width=20 height=20><img src="images/7.png" ></th><th width=50 height=20>
<input type="text" style="height:40px" placeholder="手机号/会员号/邮箱地址" size=40 id="user"></th><th width=12 height=20></th></tr>
<tr><th colspan=4 width=94 height=20></th></tr>
<tr><th width=12 height=20></th><th width=20 height=20><img src="images/8.png" ></th><th width=50 height=20>
<input type="password" style="height:40px" placeholder="?" id="password" size=40></th><th width=12 height=20></th></tr>
<tr><th colspan=4 width=94 height=20></th></tr>
<tr><th width=12 height=20></th>
<th colspan=2 width=70 height=20 bgcolor=FF5809><input type="submit" 
    style="background-color:FF5809;height:40px;width:140px;font-size:20px;color:white;border:none" 
    value="登录" ></th>
    <th width=12 height=20></th></tr>
    <tr><th colspan=4 width=94 height=20></th></tr>
<tr><th width=12 height=20></th><th width=70  height=20 colspan=2><img src="images/9.png" ></th><th width=12 height=20></th></form></tr>
<tr><th colspan=4 width=94 height=6></th></tr>
<tr><th width=12 height=40><th colspan=2><table width=310 border=0><tr><th  width=35 height=20 align='left'><font size=2>忘记密码</font></th>
<th  width=35 height=20 align='right'><font size=2><a href="zhuce.html" target="_blank">免费注册</a></font></th></tr></table></th><th></th></tr>
<tr><th colspan=4 width=94 height=6></th></tr>
</table>

</th><th width='700'></th></tr></table></th><tr><th bgcolor='f9fa9b' height=120><p>?联系邮箱:[email protected]</p><p>联系地址:</p><p>?联系电话:178****6451</p></th></table>
</body>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>注册</title>
<meta http-equiv='content-type' content='text/html;charset=utf-8'/> 
        <script type='text/javascript' src='jquery-1.7.2.js'></script> 
        <script type='text/javascript'> 
        var code ; //在全局定义验证码   
           
        function createCode(){ 
             code = "";    
             var codeLength = 4;//验证码的长度   
             var checkCode = document.getElementById("code");    
             var random = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R',   
             'S','T','U','V','W','X','Y','Z');//随机数   
             for(var i = 0; i < codeLength; i++) {//循环操作   
                var index = Math.floor(Math.random()*36);//取得随机数的索引(0~35)   
                code += random[index];//根据索引取得随机数加到code上   
            }   
            checkCode.value = code;//把code值赋给验证码   
        } 
        //校验验证码   
        function validate(){
            
            var password=document.getElementById("password").value;
            if (password.length<8){
                alert("密码至少为8位!");}
            var inputCode = document.getElementById("input").value.toUpperCase(); //取得输入的验证码并转化为大写         
            if(inputCode.length <= 0) { //若输入的验证码长度为0   
                alert("请输入验证码!"); //则弹出请输入验证码   
            }else if(inputCode != code ) { //若输入的验证码与产生的验证码不一致时   
                alert("验证码输入错误!@_@"); //则弹出验证码输入错误   
                createCode();//刷新验证码   
                document.getElementById("input").value = "";//清空文本框   
            }else { //输入正确时   
                alert("合格!^-^"); 
            } 
        } 
        </script> 
        <style type='text/css'> 
        #code{ 
            font-family:Arial,宋体; 
            font-style:italic; 
            color:blue;
            size:12px;            
            border:0; 
            padding:2px 3px; 
            letter-spacing:8px; 
            font-weight:bolder; 
        } 
        </style> 
</head>

<body onload='createCode()'>
<table border=0><tr><th width=200 height=30></th><th ><img src="images/3.jpg"></th></tr></table>
<table border=0><tr><th width=700 height=400></th><th>
<form >
<table border=0 height=400 >
<tr><th height=65><font  size='4'>用 户 名</th><th><input type="text" style="height:40px" placeholder="请输入用户名" size=40 name="username"></th></tr>
<tr><th height=65><font  size='4'>密    码</th><th><input type="password" style="height:40px" placeholder="密码长度为6~18字符" size=40 id="password"></th></tr>
<tr><th height=65><font  size='4'>确认密码</th><th><input type="password" style="height:40px" placeholder="请重新输入密码" size=40 id="password1"></th></tr>
<tr><th height=65><font  size='4'>联系方式</th><th><input type="text" style="height:40px" placeholder="+86" size=40 name="username"></th></tr>
<tr><div><th><font  size='4'>验 证 码</th><th>   
            <input type = "text" id = "input" style="height:40px;width:220px"/>   
            <input type="button" id="code" onclick="createCode()" style="height:40px;width:80px" title='点击更换验证码' /> 
            <!--<input type = "button"  style="height:40px"  value = "验证" onclick = "validate()"/> -->
            </th>
        </div>  </tr>
        
        <tr><th colspan=2 height=65><input type="checkbox"><font size='2' color='red' required/>我已阅读并同意相关条例</font></input></th></tr>
<tr><th colspan=2 height=65><input type='submit' style="background-color:red;height:55px;width:160px;font-size:25px;color:white;border:none" value='注册'id='l' onclick = "validate()" ></th></tr>
</table>
</form></th></tr></table>
<table><tr><th bgcolor='f9f8ed' height=200 width=2000><p>?联系邮箱:[email protected]</p><p>联系地址:</p><p>?联系电话:178****6451</p></th></tr></table></body>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/pengxiang1998/article/details/82762465
今日推荐