← CodePrimer
JavaScript Beginner Dom

Read input/select/textarea values

How do I read form field values in JS?

.value on controls.

Sample
const username = document.getElementById('username').value;
const course = document.getElementById('dropdown').value;
const comments = document.getElementById('comments').value;

Notes

Always trim and validate before sending to a server.

Keywords: value · input · select · textarea · form

Related

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share