我正在尝试检查复选框是否检查它是否有效
我的代码是:
<div class="container">
<form action="captcha.php" method="POST">
<div class="g-recaptcha"data-theme="dark light" data-sitekey="6LenpCATAAAAAPNX7KmRsznT15ViNFKBI80ieTUU"></div>
<input type="checkbox" name="terms" id="terms">
<p>
<button type="submit" name="submit" id="submit"class="btn btn-success" >Submit</button>
</p>
</form>
</div>
答案 0 :(得分:0)
如果隐藏条款和条件直到重新填写完成,该怎么办?我尝试了两个复选框的代码,因为recpatcha不会工作,除非小提琴网址包含在谷歌的recaptcha设置中。
$(document).ready(function() {
$('#submit').attr({disabled: 'disabled'});
$('#terms').hide();
$(document).on('click', function(event) {
enableSubmit();
});
$(document).on('change','#g-recaptcha-response', function() {
enableSubmit();
});
function enableSubmit() {
if($('#g-recaptcha-response').val() !== '') {
console.log('in if ');
$('#terms').show();
if($('#terms').is(':checked')) {
$('#submit').removeAttr('disabled');
}
else
{
console.log('in else ');
$('#submit').attr({
disabled: 'disabled'
});
}
}
};
两个复选框
$(document).ready(function() {
$('#submit').attr({
disabled: 'disabled'
});
$('#terms1').hide();
$(document).on('click', function(event) {
enableSubmit();
});
$(document).on('change','#terms', function() {
enableSubmit();
});
function enableSubmit() {
if($('#terms').is(':checked')) {
console.log('in if ');
$('#terms1').show();
if($('#terms').is(':checked') && $('#terms1').is(':checked')) {
$('#submit').removeAttr('disabled');
}
} else {
console.log('in else ');
$('#submit').attr({
disabled: 'disabled'
});
}
};
});