Javascript error in Contact form 7?
-
I am receiving a JS error which I believe is associated to JS in Contact Form 7. I am getting this message: (index):1968 Uncaught ReferenceError: grecaptcha is not defined
at (index):1968Recaptcha v3 is correctly set up for this site and the contact forms have been working.
Here is the script showing the error for the home page for this site (I’ve marked the error line with tags):
<script type=”text/javascript”>
( function( grecaptcha, sitekey, actions ) {var wpcf7recaptcha = {
execute: function( action ) {
grecaptcha.execute(
sitekey,
{ action: action }
).then( function( token ) {
var forms = document.getElementsByTagName( ‘form’ );for ( var i = 0; i < forms.length; i++ ) {
var fields = forms[ i ].getElementsByTagName( ‘input’ );for ( var j = 0; j < fields.length; j++ ) {
var field = fields[ j ];if ( ‘g-recaptcha-response’ === field.getAttribute( ‘name’ ) ) {
field.setAttribute( ‘value’, token );
break;
}
}
}
} );
},executeOnHomepage: function() {
wpcf7recaptcha.execute( actions[ ‘homepage’ ] );
},executeOnContactform: function() {
wpcf7recaptcha.execute( actions[ ‘contactform’ ] );
},};
grecaptcha.ready(
wpcf7recaptcha.executeOnHomepage
);document.addEventListener( ‘change’,
wpcf7recaptcha.executeOnContactform, false
);document.addEventListener( ‘wpcf7submit’,
wpcf7recaptcha.executeOnHomepage, false
);} )(
grecaptcha,
‘6LcxIMAUAAAAAB_GL_K27rQ6-2E1Mcc0qprRj9qZ’,
{“homepage”:”homepage”,”contactform”:”contactform”}
);
</script>The page I need help with: [log in to see the link]
The topic ‘Javascript error in Contact form 7?’ is closed to new replies.