Heim > Fragen und Antworten > Hauptteil
P粉0601123962023-09-05 09:22:20
全部排序
</div> <div id="content"> <form action="Validation" method="post" onsubmit="return submitUserForm();"> <table> <tr><td>用户名:</td><td><input type="text" name="username" value="<%=username%>" /></td></tr> <tr><td>密码:</td><td><input type="password" name="password" value="<%=password%>"/></td></tr> <tr > <td colspan="2"> <div class="g-recaptcha" data-sitekey="我的站点密钥" data-callback="verifyCaptcha"></div> <div id="g-recaptcha-error"></div> </td> </tr> <tr><td><input type="submit" name="Login" value="登录"/></td></tr> </table> </form> <script src='https://www.google.com/recaptcha/api.js'></script> <script> var recaptcha_response = ''; function submitUserForm() { if(recaptcha_response.length === 0) { document.getElementById('g-recaptcha-error').innerHTML = '<span style="color:red;">此字段为必填项。</span>'; return false; } return true; } function verifyCaptcha(token) { recaptcha_response = token; document.getElementById('g-recaptcha-error').innerHTML = ''; } </script>