Fix WAVE error on reCAPTCHA: Missing form label.

Using Gravity Forms #

To fix the “Missing form label” WAVE error on reCAPTCHA v3 when using Gravity Forms, add the following code to your functions.php file:

				
					/**
 * Fix WAVE error: "Missing form label" on Google reCAPTCHA v3.
 */
add_action( 'wp_enqueue_scripts', function() {
	if ( class_exists( 'Gravity_Forms\Gravity_Forms_RECAPTCHA\GF_RECAPTCHA' ) ) {
		wp_add_inline_script(
			'gforms_recaptcha_recaptcha',
			'(function($){grecaptcha.ready(function(){$(\'.grecaptcha-badge\').css(\'visibility\',\'hidden\');$response=$(\'.g-recaptcha-response\');$response.attr(\'aria-hidden\',\'true\');$response.attr(\'aria-label\',\'Ignore this field.\');});})(jQuery);'
		);
	}
}, 99 );

				
			

If you are still using reCAPTCHA v2 (with Gravity Forms), add this code to your javascript file instead:

				
					/**
 * Fix WAVE error: "Missing form label" on Google reCAPTCHA v2.
 */
if ( 'undefined' != typeof( gform ) ) {
	gform.addAction('gform_post_recaptcha_render', function (elem) {
		$response = jQuery( elem ).find( '.g-recaptcha-response' );
		$response.attr( 'aria-hidden', 'true' );
		$response.attr( 'aria-label', 'Ignore this field.' );
	});	
}

				
			

Using WPForms #

If you are using reCAPTCHA v2 with WPForms, use this code instead:

				
					/**
 * WPForms reCAPTCHA
 * 
 * WAVE Fix: missing form label on reCAPTCHA in WPForms.
 * 
 * @version 1.0.0
 */
( function( $ ) {
	$( document ).on( 'wpformsRecaptchaLoaded', function() {
		$( '.wpforms-recaptcha-hidden, .g-recaptcha-response' ).attr( 'aria-label', 'Ignore this field.' );
	} );
} )( jQuery );

				
			

Powered by BetterDocs

Newsletter

Subscribe and stay connected through our Newsletter. We send out important news, tips and special offers.

  • This field is for validation purposes and should be left unchanged.