From 59f4d229d501188d0992a3574258c706ca54e2f1 Mon Sep 17 00:00:00 2001 From: ssnukala Date: Sat, 26 Mar 2022 17:16:42 -0500 Subject: [PATCH] Update uf-jqueryvalidation-config.js Added conditions to add the JqueryValidation message under the Select2 container. and other conditions for Radio and Checkbox --- .../userfrosting/js/uf-jqueryvalidation-config.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/sprinkles/core/assets/userfrosting/js/uf-jqueryvalidation-config.js b/app/sprinkles/core/assets/userfrosting/js/uf-jqueryvalidation-config.js index d29c87fa4..ebdd4e96a 100644 --- a/app/sprinkles/core/assets/userfrosting/js/uf-jqueryvalidation-config.js +++ b/app/sprinkles/core/assets/userfrosting/js/uf-jqueryvalidation-config.js @@ -31,8 +31,14 @@ jQuery.validator.setDefaults({ errorElement: 'p', errorClass: 'error-block', errorPlacement: function(error, element) { - if(element.parent('.input-group').length) { + if (element.hasClass('js-select2') && element.next('.select2-container').length) { + error.insertAfter(element.next('.select2-container')); + } else if (element.parent('.input-group').length) { error.insertAfter(element.parent()); + } else if (element.prop('type') === 'radio' && element.parent('.radio-inline').length) { + error.insertAfter(element.parent().parent()); + } else if (element.prop('type') === 'checkbox' || element.prop('type') === 'radio') { + error.appendTo(element.parent().parent()); } else { error.insertAfter(element); } @@ -46,4 +52,4 @@ jQuery.validator.setDefaults({ // Add a new check mark jQuery(element).after(''); } -}); +}); \ No newline at end of file