/* global jQuery */
(function ($) {
  "use strict";

  $(function () {
    const $form = $("#kidsEnrollmentForm");
    const $feedback = $("#formFeedback");

    if (!$form.length) {
      return;
    }

    $form.on("submit", function (event) {
      event.preventDefault();
      event.stopPropagation();

      const isValid = this.checkValidity();
      $form.addClass("was-validated");

      if (!isValid) {
        $feedback
          .removeClass("d-none alert-success")
          .addClass("alert-danger")
          .text("Please complete the required fields before submitting.");
        return;
      }

      $feedback
        .removeClass("d-none alert-danger")
        .addClass("alert-success")
        .text("Enrollment details submitted successfully.");
    });
  });
})(jQuery);


