How to get HTML form values with JavaScript?

Spread the love

Sometimes, we want to get HTML form values with JavaScript.

In this article, we’ll look at how to get HTML form values with JavaScript.

How to get HTML form values with JavaScript?

To get HTML form values with JavaScript, we use the value property.

For instance, we write

<input type="text" name="name" id="uniqueID" value="value" />

to add an input.

Then we write

const nameValue = document.getElementById("uniqueID").value;

to select the input with getElementById.

And then we get its value with the value property.

Conclusion

To get HTML form values with JavaScript, we use the value property.

Leave a Reply

Your email address will not be published. Required fields are marked *