标签:错误 用户名 mys hold ext word 输入密码 表单 end
登录功能完成:
onclick="return fnLogin()"
session:
import os
DEBUG = True
SECRET_KEY = os.urandom(24)
DIALECT = ‘mysql‘
DRIVER = ‘mysqldb‘
USERNAME = ‘root‘
PASSWORD = ‘ROOT‘
HOST = ‘127.0.0.1‘
DATABASE = ‘mytest‘
SQLALCHEMY_DATABASE_URI = ‘mysql+pymysql://root:123456@127.0.0.1:3306/mytest?charset=utf8‘
SQLALCHEMY_TRACK_MODIFICATIONS = False
<!DOCTYPE html> <html lang="en"> <head> {% extends ‘test1.html‘ %} <meta charset="UTF-8"> <title>{% block title %} 登录界面 {% endblock %} </title> {% block head %} <link rel="stylesheet" type="text/css" href="../static/css/denlu.css"> <script src="../static/js/return.js"></script> {% endblock %} </head> <body> {% block body %} <div class="box"> <h1>登录</h1> <form action="{{ url_for(‘deng‘) }}" method="post"> <div class="input_box"> <input id="name" type="text" placeholder="请输入用户名" name="username"> </div> <div class="input_box"> <input id="pass" type="password" placeholder="请输入密码" name="password"> </div> <div id="error_box"><br> </div> <div class="input_box"> <button onclick="fnLogin()">登录</button> </div> </form> </div> {% endblock %} </body> </html>
function fnLogin() { var oUname = document.getElementById("name"); var oUpass = document.getElementById("pass"); var oError = document.getElementById("error_box"); var isError = true; oError.innerHTML = ‘<br>‘ // if (oUname.value.length > 20 || oUname.value.length < 6) { oError.innerHTML = "name:6-20位"; isError = false; return isError; } else if ((oUname.value.charCodeAt(0) >= 48) && (oUname.value.charCodeAt(0) <= 57)) { oError.innerHTML = "first letter."; isError = false; return isError; } else for (var i = 0; i < oUname.value.length; i++) { if ((oUname.value.charCodeAt(i) < 48) || (oUname.value.charCodeAt(i) > 57) && (oUname.value.charCodeAt(0) < 97) || (oUname.value.charCodeAt(0) > 122)) { oError.innerHTML = "only letter or number"; isError = false; return isError; } } if (oUpass.value.length > 20 || oUpass.value.length < 6) { oError.innerHTML = "password:6-20"; isError = false; return isError; } return isError; window.alert("登录成功!") }
标签:错误 用户名 mys hold ext word 输入密码 表单 end
原文地址:http://www.cnblogs.com/caoxinwen092/p/7879715.html