Answers for "javascript input value check"

1

javascript get value of input on button click

<form action="/">
  <label for="">Whatever you want</label>
  <input type="text" id='form'>
  <input type="submit" id="submit">
</form>

<script>
  const btn = document.getElementById('form');
  
  btn.addEventListener('click', (e) => {
  	e.preventDefault(); // disable the refresh on the page when submit
    const value = document.getElementById('submit').value;
    
    console.log(value);
  });
</script>
Posted by: Guest on January-25-2021

Code answers related to "javascript input value check"

Browse Popular Code Answers by Language