Javascript: Remove validation status from blocked input (already checked)

I am trying this function to check the element, and if it is installed or not, add or remove the appropriate class name. Also, if the item is disabled but it is installed, it should check it and remove the class name ("yes")

function init() {
    $(document.body).select('input').each(function(element) {
        if (!element.checked) {
            element.up().removeClassName('yes');
        } else {
            element.up().addClassName('yes');
        }
        if (element.checked && element.disabled) {
            element.checked = false;
            element.up().removeClassName('yes')
        }
    });

}

      

At the moment the last part is not working, the effect

+2


a source to share


1 answer


Have you tried element.checked = !element.checked

the last part instead element.checked = false

?



0


a source







All Articles