同题,不复述
附上md5.js原文件下载地地址:
md5.js
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录</title>
<script src="{% static '/md5.js'%}"></script>
<script type="text/JavaScript">
function gook() {
var S,X;
S = document.getElementById("username");
if (S.value == "")
{
alert("用户名不可为空");
S.focus();
return;
}
S = document.getElementById("userpw");
if (S.value == "")
{
alert("密码不可为空");
S.focus();
return;
}
else
{
var hash = md5(S);
document.getElementById("pwmd5").value = hash;
}
var f = document.getElementById("userlogin");
f.submit();
}
</script>
</head>
<body>
<table width="300" border="1">
<form action="/postmain/" method="post" id="userlogin" name="userlogin">
用户名:<input type="text" name="username" id="username"/>
密 码:<input type="password" name="userpw" id="userpw"/>
<input type="hidden" name="pwmd5" id="pwmd5"/>
<input type="hidden" name="logined" value="True" id="logined"/>
<td><a href="#" onclick="gook()">登录</a></td>
</form>
</table>
</body>
</html>