删除必需的属性 google 重新捕获 v3
Remove required attribute google recapture v3
我在表单上有一个 Google 重新捕获,不幸的是,该表单未绑定模型,因此模型验证不起作用。我使用表单集合来处理控制器中表单提交的值。如果未在控制器中检查验证码并重定向回表单,我可以阻止表单提交,但是因为不是模型绑定,所以所有值都被清除,这对 users.This 来说很痛苦,要求我验证 Google 验证码在客户端使用 JavaScript 不是很擅长。
在表格上
<div class="control-group">
<label class="control-label" for="CaptchaDeText"></label>
<div style="position:relative">
<div class="g-recaptcha" data-sitekey="xxxxxxx"></div>
<input id='recaptcha_check_empty' required tabindex='-1',style='width:50px;
height:0; opacity:0;pointer-events:none;position:absolute;bottom:0;'>
</div>
</div>
提交时调用的 Javascipt 函数
function isCaptchaChecked() {
var capcha = false;
if (grecaptcha && grecaptcha.getResponse().length !== 0) {
$('#recaptcha_check_empty').find('.control-group').removeClass('error');
capcha = true;
return true;
};
if (!capcha) {
$('#modalMessage').find('#modalBody').html(noCaptchaMessage);
$('#modalMessage').modal('show');
$('#recaptcha_check_empty').find('.control-group').addClass('error');
};
return false;
}
我的问题是当用户通过验证时如何删除必需的属性
$('#recaptcha_check_empty').removeAttr('required');
我在表单上有一个 Google 重新捕获,不幸的是,该表单未绑定模型,因此模型验证不起作用。我使用表单集合来处理控制器中表单提交的值。如果未在控制器中检查验证码并重定向回表单,我可以阻止表单提交,但是因为不是模型绑定,所以所有值都被清除,这对 users.This 来说很痛苦,要求我验证 Google 验证码在客户端使用 JavaScript 不是很擅长。
在表格上
<div class="control-group">
<label class="control-label" for="CaptchaDeText"></label>
<div style="position:relative">
<div class="g-recaptcha" data-sitekey="xxxxxxx"></div>
<input id='recaptcha_check_empty' required tabindex='-1',style='width:50px;
height:0; opacity:0;pointer-events:none;position:absolute;bottom:0;'>
</div>
</div>
提交时调用的 Javascipt 函数
function isCaptchaChecked() {
var capcha = false;
if (grecaptcha && grecaptcha.getResponse().length !== 0) {
$('#recaptcha_check_empty').find('.control-group').removeClass('error');
capcha = true;
return true;
};
if (!capcha) {
$('#modalMessage').find('#modalBody').html(noCaptchaMessage);
$('#modalMessage').modal('show');
$('#recaptcha_check_empty').find('.control-group').addClass('error');
};
return false;
}
我的问题是当用户通过验证时如何删除必需的属性
$('#recaptcha_check_empty').removeAttr('required');