I have a form with Recaptcha enabled. If the user does NOT verify the Recaptcha and hits submit he/she is prompted to verify by an error message. Then they verify but the submit button remains disabled and the form cannot be submitted. How can I remove the disabled attribute once the Recapthca is verified without the form being refreshed.
My code so far:
$(".elq-form").validate({
submitHandler: function (form) {
var captcha = grecaptcha.render('evbox-recaptcha', {'sitekey' :
'my_key'});
var response = grecaptcha.getResponse(captcha);
//recaptcha failed validation
if (response.length === 0) {
grecaptcha.reset(captcha);
$('#recaptcha-error').show();
return false;
}
//recaptcha passed validation
else {
$('#recaptcha-error').hide();
$('#submit').attr("disabled",false);
return true;
}
}
});
<p class="field-p">
<div id="recaptcha-error" style="display: none">
<p>[[%site.text.recaptcha? &topic=`default` &namespace=`site`]]</p>
</div>
<div id="evbox-recaptcha" class="g-recaptcha" data-sitekey="my_key"></div>
<input id="submit" name="submit" type="submit" value="[[%site.button.submit? &topic=`default` &namespace=`site`]]" class="submit-button button button__primary" />
</p>