+ 2

Validation form checkbox JS

Hello, everyone! The checkbox validation doesn't work in my code. When agreement is not checked everything is okay, fields are red, added class error. But as I checked agreement, nothing is happening, class is still error and the fields is red. Please, I need your help! https://code.sololearn.com/W62xfOugew4j/?ref=app

1st Dec 2021, 6:25 PM
Elena
Elena - avatar
2 ответов
+ 2
You're getting the div with the id checkbox-mark, use this instead: const agreement = document.querySelector('#input-checkbox'); That worked for me.
1st Dec 2021, 11:13 PM
Paul Grasser
Paul Grasser - avatar
+ 2
Paul, it really works! Thank you very much! I am so happy 😊
2nd Dec 2021, 4:17 AM
Elena
Elena - avatar