-3

I have created a contact Form and I try to get the data of the name, email and message inputs trough a function when I trigger the Send Message button but the data do not print them out, are null, why?.

This is the name Field, the name class into the input enter image description here

This is the email Field, the email class into the input

enter image description here

This is the Message Field, the class message into the text area.

enter image description here

This is the function that triggers

enter image description here

This are the fields

enter image description here

And I get this when I trigger the function through the Sens Message Button.

enter image description here

Why do not store the data and print them out? Thank for you help guys.

  • Please don't post text content as images. – trincot May 14 '21 at 07:37
  • "DO NOT post images of code, data, error messages, etc. - copy or type the text into the question." - https://stackoverflow.com/help/how-to-ask – LaytonGB May 14 '21 at 07:38
  • You haven't added either and `id` or `name` attribute. It's a good idea to use the id rather than a class name for specific form elements as id's should be unique within the document but class names are designed not to be. – phuzi May 14 '21 at 07:40
  • 4
    For inputs you should use `value` not `nodeValue`. – phuzi May 14 '21 at 07:41
  • SORRY GUYS FOR THE IMAGES, WILL NOR DO THAT AGAIN. Thanks @phuzi, that was the problem. – Programmer ROMERO May 14 '21 at 08:06

1 Answers1

0

In your trigger() function, you should change .nodeValue to .value, so you get:

function trigger() {
    let name = document.querySelector('.name').value;
    let email = document.querySelector('.email').value;
    let message = document.querySelector('.message').value;
};