首页 > 开发 > AJAX > 正文

基于Ajax和forms组件实现注册功能的实例代码

2024-09-01 08:26:57
字体:
来源:转载
供稿:网友

前端HTML

<!DOCTYPE html>{% load static %}{% get_static_prefix as getstatic %}<html lang="zh-CN"><head>  <meta charset="UTF-8">  <meta http-equiv="x-ua-compatible" content="IE=edge">  <meta name="viewport" content="width=device-width, initial-scale=1">  <link rel="icon" href="https://www.jd.com/favicon.ico">  <link href="{{ getstatic }}plugins/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">  <title>注册页面</title>  <style>    .title-top {      padding: 0;      font-size: 21px;      margin-top: 40px;    }    .form-padding {      padding-right: 65px;    }    .has-feedback .country-code {      width: 53px;      text-align: right;      padding-right: 5px;    }    .mobile-control-wrap {      display: flex;    }    .mobile-num {      margin-left: 10px;    }    .form-horizontal .form-group {      margin-right: -15px;      margin-left: -15px;    }    .body-box {      margin-top: 70px;      height: 567px;      width: 68%;    }    .cnblogs-btn-blue {      color: white;      padding: 6px 14px;      letter-spacing: 1em;      padding-left: 2em;      background-color: RGB(70, 136, 214);      text-align: center;    }    .cnblogs-btn-blue :hover {      color: white;    }    .navbar {      background-color: RGB(40, 62, 92);    }    .side-img-box {      height: 300px;      position: relative;      padding-left: 0;      margin-top: 168px;    }    .side-img-box img {      position: relative;      width: 100%;      top: 50%;      transform: translateY(-50%);      border-radius: 8px;    }    .text-danger {      float: right;    }    .img-thumbnail {      width: 100px;      height: 100px;      margin-bottom: 20px;      margin-top: -10px;    }    #avatr_img {      margin-left: 237px;    }  </style></head><body><nav class="navbar navbar-inverse navbar-fixed-top">  <div class="container">    <!-- Brand and toggle get grouped for better mobile display -->    <div class="navbar-header">      <img src="{{ getstatic }}img/TIM截图20180205110238.png">    </div>    <!-- Collect the nav links, forms, and other content for toggling -->    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">      <ul class="nav navbar-nav navbar-right">        <li><a href="#">首页</a></li>        <li><a href="#">登录</a></li>        <li><a href="#">注册</a></li>        <li><a href="#">帮助</a></li>      </ul>    </div><!-- /.navbar-collapse -->  </div><!-- /.container-fluid --></nav><div class="container body-box" style="height: 567px;">  <div class="center-block body-content">    <!--头部提示-->    <div class="hidden-xs title-top col-sm-12">      注册新用户      <hr class="head-hr">    </div>    <div class="form-wrap">      <form class="form-horizontal col-sm-8 form-padding" role="form" id="registerForm" method="post"         novalidate="novalidate">        <!--每一行-->        <div id="avatr_img" class="form-group">          <label for="avatar">            <img id="avatar_img" class="img-thumbnail" src="{{ getstatic }}img/registersideimg.png" alt="用户头像">            头像          </label>            <input type="file" style="display: none;" id="avatar">        </div>        <div class="form-group">          <div class="col-sm-2 control-label">            <label class="w4-2" for="Email">邮       箱</label>          </div>          <div class="col-sm-10 has-feedback">            {{ register_form.email }}            <span class="text-danger"></span>          </div>        </div>        <div class="form-group">          <div class="col-sm-2 control-label">            <label class="w4-4" for="DisplayName">昵称</label>          </div>          <div class="col-sm-10 has-feedback">            {{ register_form.nik_name }}            <span class="text-danger field-validation-error"><span id="DisplayName-error"></span></span>          </div>        </div>        <div class="form-group">          <div class="col-sm-2 control-label">            <label class="w4-2" for="Password">密       码</label>          </div>          <div class="col-sm-10 has-feedback">            {{ register_form.password }}            <span class="text-danger field-validation-error"></span>          </div>        </div>        <div class="form-group">          <div class="col-sm-2 control-label">            <label class="w4-4" for="ConfirmPassword">确认密码</label>          </div>          <div class="col-sm-10 has-feedback">            {{ register_form.repeta_pwd }}            <span class="text-danger field-validation-error"><span id="mobile-error"></span></span>          </div>        </div>        <!--注册按钮-->        <div class="form-group">          <div class="col-sm-offset-2 col-sm-10">            <span class="col-sm-12 ajax-error"></span>            <input id="submitBtn" onclick="regesite()" type="button"                class="btn ladda-button center-block cnblogs-btn-blue" value="登录">          </div>        </div>        <!--协议提示-->        <div class="col-sm-offset-2 register-sign">          <span class="asterisk">*</span> “注册” 按钮,即表示您同意并愿意遵守 <a class="look-agreeon" target="_blank"                                      href="//passport.cnblogs.com/agreement.html">用户协议</a>。        </div>        <!--hidden-->        {% csrf_token %}      </form>      <div class="hidden-xs col-sm-4 side-img-box">        <div class="side-line">          <div></div>        </div>        <img src="{{ getstatic }}img/registersideimg.png">      </div>    </div>  </div></div><script src="{{ getstatic }}js/jquery-3.2.1.min.js"></script><script src="{{ getstatic }}plugins/bootstrap-3.3.7/js/bootstrap.min.js"></script></body></html>            
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表