| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>用户注册</title>
- <script src="js/jquery-2.1.4.min.js"></script>
- <style>
- /* 全局样式重置 */
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
- }
- /* 页面背景与居中布局 */
- body {
- background-color: #f8f9fa;
- min-height: 100vh;
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 20px;
- }
- /* 注册卡片容器 */
- .register-card {
- background: #ffffff;
- border-radius: 10px;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
- width: 100%;
- max-width: 400px;
- padding: 40px 30px;
- }
- /* 标题样式 */
- .register-title {
- text-align: center;
- color: #333;
- font-size: 24px;
- margin-bottom: 30px;
- font-weight: 600;
- }
- /* 表单项样式 */
- .form-item {
- margin-bottom: 20px;
- }
- /* 标签样式 */
- .form-item label {
- display: block;
- margin-bottom: 8px;
- color: #555;
- font-size: 14px;
- }
- /* 输入框样式 */
- .form-item input {
- width: 100%;
- height: 45px;
- padding: 0 15px;
- border: 1px solid #e0e0e0;
- border-radius: 6px;
- font-size: 15px;
- outline: none;
- transition: all 0.3s ease;
- }
- /* 输入框聚焦效果 */
- .form-item input:focus {
- border-color: #409eff;
- box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
- }
- /* 输入框占位符样式 */
- .form-item input::placeholder {
- color: #999;
- font-size: 14px;
- }
- /* 注册按钮样式 */
- .register-btn {
- width: 100%;
- height: 48px;
- background-color: #409eff;
- color: #ffffff;
- border: none;
- border-radius: 6px;
- font-size: 16px;
- font-weight: 500;
- cursor: pointer;
- transition: background-color 0.3s ease;
- margin-top: 10px;
- }
- /* 按钮hover效果 */
- .register-btn:hover {
- background-color: #3399ff;
- }
- /* 按钮禁用状态(可选) */
- .register-btn:disabled {
- background-color: #a0cfff;
- cursor: not-allowed;
- }
- </style>
- </head>
- <body>
- <div class="register-card">
- <h1 class="register-title">用户注册</h1>
- <form action="">
- <div class="form-item">
- <label for="username">账号</label>
- <input type="text" placeholder="注册用户名" name="username" id="username">
- </div>
- <div class="form-item">
- <label for="password">密码</label>
- <input type="password" placeholder="注册密码" name="password" id="password">
- </div>
- <input type="button" onclick="register()" value="注册" class="register-btn">
- </form>
- </div>
- <script>
- function register(){
- var username = $("input[name='username']").val().trim();
- var password = $("input[name='password']").val().trim();
- // 简单的非空验证(新增)
- if(!username) {
- alert("请输入用户名!");
- return;
- }
- if(!password) {
- alert("请输入密码!");
- return;
- }
- $.post("/register",{username:username,password:password},function (result) {
- if(result.success){
- alert("注册成功");
- }else{
- alert(result.msg || "注册失败,请重试");
- }
- }).fail(function() {
- // 新增网络异常提示
- alert("网络异常,注册请求发送失败!");
- });
- }
- </script>
- </body>
- </html>
|