diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index dfd3687e..979fadb6 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -3610,28 +3610,39 @@ let hasEmptyInsurer = false; let firstEmptyField = null; + // $('select[name="follow_insurer_id[]"]').each(function() { + // const $field = $(this); + // const errorId = 'error-' + $field.attr('id'); + + // // Remove any old message + // $('#' + errorId).remove(); + + // if ($field.val().trim() === "") { + // hasEmptyInsurer = true; + // $field.addClass('is-invalid'); + + // // Add error message only once + // if (!$field.next('.text-danger').length) { + // $field.after(`This value is required.`); + // } + + // if (!firstEmptyField) { + // firstEmptyField = this; // store first empty field + // } + // } else { + // $field.removeClass('is-invalid'); + // $('#' + errorId).remove(); // remove if filled + // } + // }); $('select[name="follow_insurer_id[]"]').each(function() { - const $field = $(this); - const errorId = 'error-' + $field.attr('id'); - - // Remove any old message - $('#' + errorId).remove(); - - if ($field.val().trim() === "") { + if ($(this).val().trim() === "") { hasEmptyInsurer = true; - $field.addClass('is-invalid'); - - // Add error message only once - if (!$field.next('.text-danger').length) { - $field.after(`This value is required.`); - } - + $(this).addClass('is-invalid'); if (!firstEmptyField) { - firstEmptyField = this; // store first empty field + firstEmptyField = this; // store the first invalid field } } else { - $field.removeClass('is-invalid'); - $('#' + errorId).remove(); // remove if filled + $(this).removeClass('is-invalid'); } }); @@ -4570,7 +4581,7 @@ switch(index) { case 0: // Insurer selection newCell = `