Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
1.9 kB
24
Indexable
Never
  <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) {
              event.preventDefault;
              if (validFirstName(form.firstName)|| validLastName(form.lastName)||validMessage(form.message)) {
                errorMessage.style.display = 'block';
              } else {
                errorMessage.style.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 = "";
            }

  
          </script>
          <!--Fin du Script-->
Leave a Comment