I’m not able to get the following code to work:
$(function() {
function verifyRecaptcha() {
return new Promise((resolve, reject) => {
grecaptcha.execute('RECAPTCHA_SITE_KEY', {action: 'submit'}).then(function(token) {
postJson('frontend/verify_recaptcha/'+token, null, function(d) {
if (d.pass) {
resolve('Verified');
} else {
reject('Not verified');
}
});
});
});
};
var parsleyForm = $('#enquiry-form').parsley().on('form:submit', function(formInstance) {
var validationResult = false;
verifyRecaptcha().then(function() {
console.log('VERIFIED');
validationResult = true
}).catch(function() {
console.log('NOT VERIFIED');
validationResult = false;
});
console.log('Resultat: '+validationResult);
return validationResult;
});
});
I already tried a lot with await/async, but it always submits the form.
I think I cannot be the only one who needs to implement Parsley with recaptcha v3? Any ideas? 🙂