Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

fixing of mandatory field handling #9

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function validateForm(isCreateForm) {

requiredFields.forEach(function (field) {
var existingErrorMessage = field.parentNode.querySelector(".error-message");
if (!field.value.trim() && field.offsetWidth > 0 && field.offsetHeight > 0) {
if (!field.value.trim()) {
var errorMessage = document.createElement("span");
errorMessage.className = "error-message";
errorMessage.textContent = "This field is required";
Expand All @@ -28,6 +28,13 @@ function validateForm(isCreateForm) {

field.style.border = "1px solid red";
isValid = false;
const collapseElement = field.closest(".collapse");
if (collapseElement) {
const accordionButton = document.querySelector(`[data-bs-target="#${collapseElement.id}"]`);
if (accordionButton) {
accordionButton.click();
}
}
} else {
if (existingErrorMessage) {
existingErrorMessage.parentNode.removeChild(existingErrorMessage);
Expand Down
Loading