AI Workshop: learn to build apps with AI →
File APIs: Check if checkbox is checked

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


Use the checked property of the checkbox element. Example:

<input type="checkbox" class="checkbox" />

To check whether it is checked:

document.querySelector('.checkbox').checked

Alternatively, check whether a checked checkbox exists:

document.querySelector('.checkbox:checked') !== null

Using the .checked property is usually clearer.

Do not use getAttribute('checked') to determine checked state; the attribute does not reflect user toggles. For example:

<input type="checkbox" checked />

Do not rely on the checkbox’s value for checked state—it is always on when present.

Lessons in this unit:

0: Introduction
1: The File object
2: FileList
3: FileReader
4: Blob
5: FormData
6: Accept only images in file input
7: ▶︎ Check if checkbox is checked
8: Reset a form
9: File upload with server handling
10: Drag and drop file upload
11: Validating file size before upload