我对Django非常陌生,所以jQuery在这里需要一些帮助(基本上是一个菜鸟)。我需要启用启动测试按钮后,从服务器端验证,不能绕过从前端和复选框复选框已从服务器端。我之前做过复选框,但不知道如何添加Captcha。
HTML代码
<div
class="g-recaptcha captcha-button"
align="center"
data-sitekey="sitekey"
></div>
<br />
<div class="form-check test-check-button" align="center">
<input type="checkbox" class="form-check-input display-7" id="instructions" />
<label class="form-check-label text-center" for="instructions">
<strong>I have read the instructions given above.</strong></label
>
</div>
<div class="mb-5 mt-2 text-center start-button" id="startButton"></div>
<script>
$("#instructions").on("click", function () {
$.ajax({
type: "GET",
url: "/test/confirm",
data: {
checkbox: 1,
},
dataType: "json",
success: function (data) {
if (data.button) {
$(".test-check-button").html("");
$(".start-button").html(data.button);
}
},
});
});
</script>Views.py
def confirm(cls, request: HttpRequest):
button = '<button class="btn btn-primary mt-3" id="submit_test" type="submit">Start
Test</button>'
data = {'button': button}
return JsonResponse(data)这个项目中没有forms.py。因此,我想知道如何在没有表单的情况下验证captcha服务器端,并在检查验证和复选框之后启用“开始测试”按钮。谢谢。
发布于 2020-07-04 00:00:05
有一个数据回调属性:
function myCallback(){
$('button').prop( "disabled", false )
}<div class="g-recaptcha" data-callback="myCallback"/>
https://stackoverflow.com/questions/62698522
复制相似问题