Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
Disable submit button upon revisiting the form page

Is there a way a form page can detect that after you answer the form and submits, and then REVISITS the form page, the submit button is now DISABLED?

Important Note: If a different user, the form can be answered and submitted, if the SAME user visits again the link, the submit button is DISABLED.

Is this possible using HTML, CSS and JavaScript?

<form>
  <label for="fname">First name:</label><br>
  <input type="text" id="fname" name="fname" value="First Name"><br>
  <label for="lname">Last name:</label><br>
  <input type="text" id="lname" name="lname" value="Last Name"><br><br>
  <input type="submit" value="Submit">
</form> 
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you're trying to achieve this functionality strictly client side, you can store whether the user has submitted the form in localStorage.

For example, you can add a submit event listener to the form that sets the submitted state to true in localStorage. On page load, retrieve that state, check whether it is true, and if so, whenever the user submits the form, prevent form submission.

For example:

const form = document.querySelector('form')
var isDisabled = !!localStorage.getItem('submitted');

form.addEventListener('submit', function(e){
    if(isDisabled){
    e.preventDefault();
    alert("You have already submitted")
  }
    localStorage.setItem('submitted', true);
})

JsFiddle demo: https://jsfiddle.net/Spectric/dowc1qea/

Keep in mind, however, that since localStorage is modifiable by the client, they can always set the state to false programmatically and submit the form again.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda