Why .setAttribute(‘checked’, false) does not work with Contact form 7 radio button?

Question

I have the Contact form with three radio buttons. And simple text field under these radio buttons. The idea if user use input field the radio buttons should clears and contra if user checked one of the radio button the text input field should clear.

I created simple JavaScript code for this propose:

    let inputValue = $('.vaucher_value').find('input');
    let customValue = $('.andererbetrag').find('input');

    customValue.on('input', function(){
        Array.from(inputValue).forEach(item => {
            item.setAttribute('checked', false);
            item.classList.add('unchecked')
        });
    })
    Array.from(inputValue).forEach(item => {
        item.addEventListener('click', function(){
            item.classList.remove('unchecked')
            item.setAttribute('checked', true)
            console.log(customValue.value)
        })
        
    });

And it work but only visual. After I sent the form I get the all field data even that Even those that have been cleansed. I lost a lot of time but I can not understand why this is happening. Please help me figure it out.

0
Victor Sokoliuk 4 months 2022-04-21T08:20:24-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse