web前端注册界面

       此注册页面,需要用户输入11位手机号和正确验证码。随机获取验证码,并对手机号长度和验证码进行校验,校验正确方可显示注册成功。同时,60秒内不能重复获取验证码。

演示

HTML源代码 


  <!DOCTYPE html>

  <html lang="en">

  <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>

  <link rel="stylesheet" href="./css/common.css">//连接

  <style>

    body {

      background: url(./img/login_bgc.jpg) no-repeat top center;

    }

    .login-logo {

      width: 93px;

      height: 92px;

      margin: 20px auto;

    }

    .wrap {

      margin: 0 auto;

      width: 380px;

      background-color: #fff;

      padding: 38px 0 22px;

      font-size: 12px;

      color: #999;

      border-radius: 5px;

    }

    .wrap input {

      box-sizing: border-box;

      display: block;

      width: 300px;

      height: 40px;

      margin-bottom: 18px;

      padding-left: 17px;

      border: 1px solid #cecece;

      border-radius: 5px;

    }

    input::-webkit-input-placeholder {

      /* WebKit browsers */

      color: #cecece;

    }

    .box {

      margin: 0 39px;

    }

    .box p {

      text-align: right;

      margin: 14px 0;

      color: #cecece;

    }

    .box p>a {

      color: #999;

    }

    .box button {

      box-sizing: border-box;

      display: block;

      width: 300px;

      height: 40px;

      margin-bottom: 18px;

      padding-left: 17px;

      border: 1px solid #cecece;

      border-radius: 5px;}

    .login-type {

      border-top: 1px solid #999;

      padding: 15px 38px 0;

    }

    .login-type ul {

      margin-top: 20px;

    }

    .login-type ul li {

      float: left;

      margin-right: 50px;

      text-align: center;

    }

    .registe {

      text-align: center;

      margin-top: 16px;

    }

    .reg {

      padding: 6px 22px;

      font-size: 12px;

      color: #fff;

      background-color: rgba(0, 0, 0, .2);

      border-radius: 5px;

    }

  </style>

</head>

<body>

  <div class="login-logo"><img src="./img/login_logo.png" alt=""></div>

  <div class="wrap">

    <div class="box">

      <form action="">

      <input type="text" placeholder="请输入您的手机号"  id="account"/>

      <button type="button" id="add" onclick="Random()">获取验证码</button>

      <input type="text"  placeholder="请输入验证码" id="num" /> 

      <input type="submit" value="立即注册" onclick="getInformation()"/>

    <script>

         function getInformation(){

            var account=document.getElementById("account").value;

            var num=document.getElementById("num").value;

            if(account==null||account==""){

            alert("手机号不能为空");

            return false;}

            if(account.length!=11){

            alert("请输入11位正确手机号");

            return false;}

            if(num==null){

            alert("验证码不能为空");

            return false;}

            if(num!=random){

            alert("验证码错误,请重新输入");

            return false;}

            else{

                alert("注册成功!");

            }

          }

      var add=document.getElementById("add")

      console.log(add)

      var random=""

      function Random(){

        random=""

        for(var i=0; i<4;i++){

          random+=Math.floor(Math.random()*10)

        }

         alert("验证码"+random)}

        // 按钮点击之后,会禁用 disabled 为true 

        // 同时按钮里面的内容会变化, 注意 button 里面的内容通过 innerHTML修改

        // 里面秒数是有变化的,因此需要用到定时器

        // 定义一个变量,在定时器里面,不断递减

        // 如果变量为0 说明到了时间,我们需要停止定时器,并且复原按钮初始状态

        var btn = document.querySelector('button');

        var time = 60; // 定义剩下的秒数

        btn.addEventListener('click', function () {

            btn.disabled = true;

            var timer = setInterval(function () {

                if (time == 0) {

                    // 清除定时器和复原按钮

                    clearInterval(timer);

                    btn.disabled = false;

                    btn.innerHTML = '获取验证码';

                    time = 60;

                } else {

                    btn.innerHTML = time + '秒后重新获取';

                    time--;

                }

            }, 1000)

        })

    </script>

        </form>

      <p>注册视为同意<a href="#">《悠游用户使用协议》</a></p>

    </div>

    <div class="login-type">

      <p>用合作网站账户直接登录</p>

      <ul class="clearfix">

        <li>

          <a href><img src="./img/weibo.png" alt=""></a>

          <p>新浪微博</p>

        </li>

        <li>

         <a href><img src="./img/QQ.png" alt=""></a> 

          <p>QQ</p>

        </li>

        <li>

          <a href><img src="./img/weixin.png" alt=""></a> 

          <p>微信</p>

        </li>

      </ul>

    </div>

  </div>

  <div class="registe">

    <span class="reg">已有帐号?<a href="login.html" style="color: #5696ff;">马上登录?</a></span>

  </div>

</body>

</html>

 外部样式表(外链式)common.css

* {
    margin: 0;
    padding: 0;
    list-style: none;
    text-decoration: none;
}
.clearfix:after {
    content: "";
    display: block;
    height: 0;
    clear: both;
}
body {
    background-color: #f3f3f3;
}
.fl {
    float: left;
}
 
.fr {
    float: right;
}
 
.nav {
    margin: 0 auto;
    width: 1200px;
    font-size: 18px;
}
 
.logo {
    margin-right: 159px;
    line-height: 72px;
}
 
.logo img {
    vertical-align: middle;
}
 
.list>li {
    float: left;
    width: 80px;
    height: 72px;
    margin-right: 24px;
    line-height: 72px;
    text-align: center;
}
 
.current {
    background-color: #5696ff;
    color: white;
}
 
.login-reg>li {
    float: left;
    line-height: 72px;
}
 
.login-middle {
    color: #999;
}
 
 
.footer {
    color: #fff;
    height: 130px;
    background-color: #6297f7;
    overflow: hidden;
}
.footer div{
    width: 660px;
    margin: 34px auto;
    text-align: left;
    line-height: 34px;
}
.end {
    margin-bottom: 66px;
}
 
 
.wrap {
    width: 1200px;
    margin: 0 auto;
}
img {
    vertical-align: middle;
}
a {
    color: #6297f7;;
}
 
.search-row {
    background-color: #666666;
    line-height: 57px;
}
 
.search-row img {
    vertical-align: middle;
    margin: 0 40px;
}
 
.search-row span {
    border-left: 1px solid #fff;
}
 
.search-row ul li {
    float: left;
}

  • 8
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的Web前端注册页面的代码示例: ```html <!DOCTYPE html> <html> <head> <title>注册页面</title> <style> body { font-family: Arial, sans-serif; background-color: #f2f2f2; } .container { max-width: 400px; margin: 0 auto; padding: 20px; background-color: #fff; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h2 { text-align: center; margin-bottom: 20px; } .form-group { margin-bottom: 20px; } .form-group label { display: block; font-weight: bold; margin-bottom: 5px; } .form-group input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 3px; } .form-group button { width: 100%; padding: 10px; background-color: #4CAF50; color: #fff; border: none; border-radius: 3px; cursor: pointer; } </style> </head> <body> <div class="container"> <h2>注册</h2> <form> <div class="form-group"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required> </div> <div class="form-group"> <label for="password">密码:</label> <input type="password" id="password" name="password" required> </div> <div class="form-group"> <label for="confirm-password">确认密码:</label> <input type="password" id="confirm-password" name="confirm-password" required> </div> <div class="form-group"> <button type="submit">注册</button> </div> </form> </div> </body> </html> ``` 这段代码实现了一个简单的注册页面,包含用户名、密码和确认密码的输入框,以及一个注册按钮。用户需要填写所有必填字段才能提交注册表单。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值