Ask coding questions

← Back to all posts
Help with Javascript
h
IntellectualGuy (658)

Hello

So in this game that I've made, I want to get the value of the input only after the user submits the form how do I do that?

Comments
hotnewtop
notGilbert (45)
// or whatever the id is
const form = document.getElementById('guess');

form.addEventListener('submit', e => {
  e.preventDefault(); // stops the page from reloading
  // do whatever you need to do
})