Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
How do I remove the input typed in by user in an input tag after form submission through vanilla javascript?

 <input type="number" class="setter" id="day-set" name="day-set" value="day"max="30" min="0" placeholder="00"onkeyup="if(parseInt(this.value)>30){ this.value =30; return false;}">

How do I make it so that the input typed in by the user in the input field is cleared when a submit button is pressed (the one which does not refreshes the page)

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

you can add this to the onclick function of your button and replace the myForm with the id of your form element

document.getElementById("myForm").reset();
about 4 years ago · Juan Pablo Isaza Denunciar

0

   <html>
    <body>
    
      <p>Clear the input field when you click on the button:</p>
      <button onclick="document.getElementById('myInput').value = ''">Clear input 
       field</button>
    
      <input type="text" value="Blabla" id="myInput">
    
    </body>
   </html>

You can also write the javaScript in-between the script tag in a Function or any other way that you want.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can create a function and add it into the onSubmit event of your form (assuming that you have a form) and then inside of that function you only need to clear the value using something like this:

document.getElementById('day-set').value = ''

Example:

<form onsubmit="myFunction()">
   <input type="number" class="setter" id="day-set" name="day-set" value="day"max="30" min="0" placeholder="00"onkeyup="if(parseInt(this.value)>30){ this.value =30; return false;}">
  <input type="submit">
</form>

<script>
 function myFunction(){
  document.getElementById('day-set').value = ''
 } 
</script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda