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 553
553
$forms = $ ( 'form' ) ;
554
554
}
555
555
556
+ var i = 0 ,
557
+ grecaptchaRenderCallback = [ ] ;
556
558
$forms . each ( function ( ) {
557
559
var $form = $ ( this ) ,
558
- config = $form . context . validationConfig ;
560
+ config = $form . context . validationConfig || false ;
561
+ if ( config ) {
559
562
560
563
$ ( '[data-validation~="recaptcha"]' , $form ) . each ( function ( ) {
561
564
var $input = $ ( this ) ,
569
572
throw new Error ( 'Google reCaptcha site key is required.' ) ;
570
573
}
571
574
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 ( ) {
574
581
$ ( '[data-validation~="recaptcha"]' , $ ( this ) ) . each ( function ( ) {
575
582
$ ( this ) . trigger ( 'validation' , ( result && result !== '' ) ) ;
576
583
} ) ;
577
584
} ) ;
578
585
} ;
586
+ grecaptchaRenderCallback [ $form . attr ( 'id' ) ] . formID = $form . attr ( 'id' ) ;
579
587
580
588
var widgetId = grecaptcha . render ( div , {
581
589
sitekey : siteKey ,
582
590
theme : theme ,
583
591
size : size ,
584
592
type : type ,
585
- callback : grecaptchaRenderCallback ,
586
- 'expired-callback' : grecaptchaRenderCallback
593
+ callback : grecaptchaRenderCallback [ $form . attr ( 'id' ) ] ,
594
+ 'expired-callback' : grecaptchaRenderCallback [ $form . attr ( 'id' ) ]
587
595
} ) ;
588
596
589
597
$input
597
605
. append ( div ) ;
598
606
599
607
} ) ;
608
+ }
600
609
601
610
} ) ;
602
611
} ;
You can’t perform that action at this time.
0 commit comments