第四周jsp作业
<%-- Created by IntelliJ IDEA. User: Dell Date: 2021/3/27 Time: 19:51 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> div { width: 160px; height: 36px; background-color: #f40; line-height: 36px; text-align: center; color: #fff; font-size: 16px; margin: 30px auto; cursor: pointer; -webkit-user-select: none; /*禁止用户选中文字*/ } </style> </head> <body> <form action="/dl_war_exploded/ss" method="post"> <table> <tr> <td>用户名:</td> <td><input type="text" name="username" class="username"> </td> </tr> <tr> <td>密 码:</td> <td><input type="password" name="password" class="password"> </td> </tr> <td>验证码:</td> <td><input type="text" name="yzm" id="inyzm"></td> </tr> <tr> <td></td> <td><div id="code_box">Af3D</div></td> </tr> <tr> <td></td> <td colspan="2"><input type="submit" value="登录" onclick="yzyzm()"> </td> </tr> </table> </form> <!--<div id="code_box">Af3D</div>--> <script> var result; var code_box = document.getElementById("code_box"); function refreshCode() { var code = '0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM', char = '', result = ''; for (var i = 0; i < 4; i++) { var code_index = Math.round(Math.random()*61); var char = code[code_index]; if (result.toUpperCase().indexOf(char.toUpperCase()) > -1) { i --; continue; } result += char; } code_box.innerHTML = result; } //点击事件 code_box.onclick = refreshCode; function yzyzm() { var inyzm = document.getElementById("inyzm").value; if(inyzm!==result.toLowerCase()){ alert("验证码输入错误"); } } </script> </body> </html>