@@ -27,7 +27,29 @@ function init() {
2727 initTooltips ( ) ;
2828
2929 if ( $ ( 'form' ) . length ) {
30- $ ( 'form' ) . not ( '.no-check' ) . parsley ( ) ;
30+ // Configurazione per posizionare correttamente i messaggi di errore di Parsley.js
31+ $ ( 'form' ) . not ( '.no-check' ) . parsley ( {
32+ errorsContainer : function ( parsleyField ) {
33+ // Per i campi dentro input-group, crea un contenitore dopo l'input-group
34+ var $inputGroup = parsleyField . $element . closest ( '.input-group' ) ;
35+ if ( $inputGroup . length ) {
36+ var containerId = 'parsley-errors-' + parsleyField . $element . attr ( 'name' ) ;
37+ var $container = $ ( '#' + containerId ) ;
38+
39+ // Se il contenitore non esiste, crealo dopo l'input-group
40+ if ( ! $container . length ) {
41+ $container = $ ( '<div id="' + containerId + '" class="parsley-errors-container"></div>' ) ;
42+ $inputGroup . after ( $container ) ;
43+ }
44+
45+ return $container ;
46+ }
47+ // Altrimenti usa il comportamento predefinito
48+ return parsleyField . $element . parent ( ) ;
49+ } ,
50+ errorsWrapper : '<div class="parsley-errors-list"></div>' ,
51+ errorTemplate : '<div class="parsley-error-message"></div>'
52+ } ) ;
3153
3254 if ( window . CKEDITOR ) {
3355 CKEDITOR . on ( 'instanceReady' , function ( ) {
@@ -75,6 +97,14 @@ function init() {
7597 this . $element . removeClass ( 'parsley-success' ) ;
7698 } ) ;
7799
100+ // Ripristina il pulsante di login quando la validazione fallisce
101+ window . Parsley . on ( 'field:error' , function ( ) {
102+ var $loginButton = $ ( '#login-button' ) ;
103+ if ( $loginButton . length && $loginButton . html ( ) . indexOf ( 'Autenticazione' ) !== - 1 ) {
104+ $loginButton . html ( '<i class="fa fa-sign-in mr-2"></i> Accedi' ) ;
105+ }
106+ } ) ;
107+
78108 restart_inputs ( ) ;
79109}
80110
0 commit comments