help correct the error with validation. The challenge is this:
There is a check boxes and input field. if any of the check boxes is marked, and nothing is entered in the input field, a validation prohibiting the sending of the form should work and div.demo will be red framed. it works, but if I mark and enter text, then when sending it is still marked with a frame. in javascript is not strong. I can not figure out what I'm doing wrong.
$('.checker').change(function() { if (this.checked) { $('#altField').prop('required', true); if ($("#altField").val().length === 0) { $("button").click(function() { $(".demo").addClass("redb"); }); } } else { $('#altField').prop('required', false); $("button").click(function() { $(".demo").removeClass("redb"); }); } });