diff --git a/main/_front/src/js/add-edit.js b/main/_front/src/js/add-edit.js index 6e55542..97ffdde 100644 --- a/main/_front/src/js/add-edit.js +++ b/main/_front/src/js/add-edit.js @@ -230,8 +230,22 @@ const addProperty = (element, name, value) => { } } + const property_btn = document.querySelector("#property_btn"); property_btn.addEventListener('click', (e) => { + let otherPropertiesArray = [] + other_properties.querySelectorAll(".property").forEach(property => { + otherPropertiesArray.push(property.querySelector(".property__name").textContent) + }) + console.log(otherPropertiesArray); + for (let i = 0; i < otherPropertiesArray.length; i++) { + console.log(input_property_name.value.trim()) + console.log(otherPropertiesArray[i]) + if (input_property_name.value.trim() === otherPropertiesArray[i].trim()){ + alert("Нельзя добавить свойство с таким же именем") + return; + } + } const input_name = input_property_name.value; const input_value = input_property_value.value; if (input_name !== "" && input_value !== "") {