Files

53 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const form = document.getElementById('editPrestationForm');
const titleField = document.getElementById('prestationTitle');
const descriptionField = document.getElementById('prestationDescription');
const typeField = document.getElementById('prestationType');
const priceMinField = document.getElementById('priceMin');
const priceMaxField = document.getElementById('priceMax');
const errorEmpty = document.getElementById('errorEmpty');
const errorTechnical = document.getElementById('errorTechnical');
const successMsg = document.getElementById('successMsg');
form.addEventListener('submit', function (e) {
e.preventDefault();
errorEmpty.classList.add('d-none');
errorTechnical.classList.add('d-none');
successMsg.classList.add('d-none');
const title = titleField.value.trim();
// champ obligatoire manquant
if (title === '') {
errorEmpty.classList.remove('d-none');
return;
}
// 2 Simulation derreur technique
const erreurTechnique = false; // mettre true pour tester
if (erreurTechnique) {
errorTechnical.classList.remove('d-none');
return;
}
//Succès
successMsg.classList.remove('d-none');
console.log("Nouvelles données :", {
titre: title,
type: typeField.value,
description: descriptionField.value,
prixMin: priceMinField.value,
prixMax: priceMaxField.value
});
// Redirection après un court délai
setTimeout(() => {
window.location.href = "../liste_prestation/liste_prestation.html";
}, 1500);
});