Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
1.8 kB
2
Indexable
Never
<!--Début du Script-->
          <script>
            const firstName = document.getElementById('first-name').value;
            const lastName = document.getElementById('last-name').value;
            const message = document.getElementById('message').value;
            const errorMessage = document.getElementById('error-message');

            //Création évenement soumission évenement
            form.addEventListener('submit', function (event) {
              e.preventDefault;
              if (validFirstName(form.firstName)|| validLastName(form.lastName)||validMessage(form.message)) {
                errorMessage.display = "block",
              } else {
                errorMessage.display = "none";
                addComment;
                clearForm;
              }
            });

            //Création de la fonction addComment
            function addComment () {
              const myContainer = document.querySelector('comment-list');
              const commentElement = document.createElement('.flex-1, .py-10');

              const commentName = document.createElement('.font-medium, .text-gray-900');
              const commentText = document.createElement('.prose, .prose-sm, .mt-4, .max-w-none, .text-gray-500');
              

              commentElement = commentName + commentText;
              commentName.textContent = firstName + " " + lastName;
 
              commentText.textContent = message;

              myContainer.appendChild('commentElement');
            }


            //Création de la fonction ClearForm
            function clearForm () {
              document.getElementById('first-name').value = "",
              document.getElementById ('last-name').value ="",
              document.getElementById('message').value = "";
            }
Leave a Comment