Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!