File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 553553 $forms = $ ( 'form' ) ;
554554 }
555555
556+ var i = 0 ,
557+ grecaptchaRenderCallback = [ ] ;
556558 $forms . each ( function ( ) {
557559 var $form = $ ( this ) ,
558- config = $form . context . validationConfig ;
560+ config = $form . context . validationConfig || false ;
561+ if ( config ) {
559562
560563 $ ( '[data-validation~="recaptcha"]' , $form ) . each ( function ( ) {
561564 var $input = $ ( this ) ,
569572 throw new Error ( 'Google reCaptcha site key is required.' ) ;
570573 }
571574
572- var grecaptchaRenderCallback = function ( result ) {
573- $ ( 'form' ) . each ( function ( ) {
575+ if ( ! $form . attr ( 'id' ) ) {
576+ $form . attr ( 'id' , 'recaptcha-form-' + ( i ++ ) ) ;
577+ }
578+ grecaptchaRenderCallback [ $form . attr ( 'id' ) ] = function ( result ) {
579+ var formID ;
580+ $ ( '#' + formID ) . each ( function ( ) {
574581 $ ( '[data-validation~="recaptcha"]' , $ ( this ) ) . each ( function ( ) {
575582 $ ( this ) . trigger ( 'validation' , ( result && result !== '' ) ) ;
576583 } ) ;
577584 } ) ;
578585 } ;
586+ grecaptchaRenderCallback [ $form . attr ( 'id' ) ] . formID = $form . attr ( 'id' ) ;
579587
580588 var widgetId = grecaptcha . render ( div , {
581589 sitekey : siteKey ,
582590 theme : theme ,
583591 size : size ,
584592 type : type ,
585- callback : grecaptchaRenderCallback ,
586- 'expired-callback' : grecaptchaRenderCallback
593+ callback : grecaptchaRenderCallback [ $form . attr ( 'id' ) ] ,
594+ 'expired-callback' : grecaptchaRenderCallback [ $form . attr ( 'id' ) ]
587595 } ) ;
588596
589597 $input
597605 . append ( div ) ;
598606
599607 } ) ;
608+ }
600609
601610 } ) ;
602611 } ;
You can’t perform that action at this time.
0 commit comments