From ec473b05d9e66aede2d5aab014da01eb2bdc1e6e Mon Sep 17 00:00:00 2001 From: Abdi Tolessa <41271840+AbdiTolesa@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:57:21 +0300 Subject: [PATCH 1/2] Support fields validation with captcha --- js/formidable.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/formidable.js b/js/formidable.js index 618aa20f8c..a06d878fa9 100644 --- a/js/formidable.js +++ b/js/formidable.js @@ -1545,13 +1545,13 @@ function frmFrontFormJS() { return; } + errors = frmFrontForm.validateFormSubmit( object ); if ( invisibleRecaptcha.length ) { - showLoadingIndicator( jQuery( object ) ); - executeInvisibleRecaptcha( invisibleRecaptcha ); + if ( Object.keys( errors ).length === 0 ) { + showLoadingIndicator( jQuery( object ) ); + executeInvisibleRecaptcha( invisibleRecaptcha ); + } } else { - - errors = frmFrontForm.validateFormSubmit( object ); - if ( Object.keys( errors ).length === 0 ) { showSubmitLoading( jQuery( object ) ); From 6be11f4749463dcd70992e92ec2ca9a8c52ef601 Mon Sep 17 00:00:00 2001 From: Abdi Tolessa <41271840+AbdiTolesa@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:07:27 +0300 Subject: [PATCH 2/2] Refactor code a bit --- js/formidable.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/js/formidable.js b/js/formidable.js index a06d878fa9..d9e45b3865 100644 --- a/js/formidable.js +++ b/js/formidable.js @@ -1546,18 +1546,16 @@ function frmFrontFormJS() { } errors = frmFrontForm.validateFormSubmit( object ); + if ( Object.keys( errors ).length !== 0 ) { + return; + } if ( invisibleRecaptcha.length ) { - if ( Object.keys( errors ).length === 0 ) { - showLoadingIndicator( jQuery( object ) ); - executeInvisibleRecaptcha( invisibleRecaptcha ); - } + showLoadingIndicator( jQuery( object ) ); + executeInvisibleRecaptcha( invisibleRecaptcha ); } else { - if ( Object.keys( errors ).length === 0 ) { - showSubmitLoading( jQuery( object ) ); - - frmFrontForm.submitFormNow( object, classList ); - } - } + showSubmitLoading( jQuery( object ) ); + frmFrontForm.submitFormNow( object, classList ); + } }, submitFormNow: function( object ) {