M
M
Mirrrta2020-06-10 16:33:37
JavaScript
Mirrrta, 2020-06-10 16:33:37

How to check that no checkbox is checked on the page?

I have checkboxes in a form with the following structure:

<form>
  <label>
    <input type=checkbox value='1' />
  </label>
  <label>
    <input type=checkbox value='2' />
  </label>
  <button type='submit'>
</form>


When submitting, I check the data through new FormData(e.currentTarget)
But! How to make the submit button inactive if no checkbox is checked without submitting the form?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2020-06-10
@Mirrta

https://jsfiddle.net/ps6zt52a/

M
MifeeX, 2020-06-10
@MifeeX

try using Redux-form.
Well, set the button to false, and hang an event handler on the checkboxes. If the checkbox is checked, the button becomes normal, otherwise vice versa

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question