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

111
Views
Radio Input Selection not Reset Immediately in Form Reset Callback

I encountered some surprising behaviour today, whereby in a form reset event callback, the values do not appear to actually have been reset by the time the callback fires.. This seemed very strange to me..

A timeout as short as a break in flow enables access to the [expected] reset value, but without this, the input's value in the reset callback is the value before the form has actually been reset.

In the following reduced test case, if I check the 'no' radio, then click the reset button, the callback function will log 'no' then 'yes'. I would have expected that it would be 'yes' and 'yes'!

const form = document.querySelector('form');

form.addEventListener('reset', () => {
  let getVal = () => form.querySelector('input:checked').value;

  console.log(getVal());
  setTimeout(() => console.log(getVal()), 0);
});
<form>
  <div>
    <label>
      <input type="radio" name="test" value="yes" checked>Yes
    </label>
    <label>
      <input type="radio" name="test" value="no">No
    </label>
  </div>

  <button type="reset">Reset Form</button>
</form>

Is it intentional that the callback for a form reset fires before the form has actually been reset? If so, why is this? Are there any advantages of this? It would seem much more logical to me that the reset event would fire immediately after the values are reset, to allow the callback to work with them..

about 4 years ago · Juan Pablo Isaza
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!