Javascript to enable button

Asked

Viewed 170 times

0

I have a term of use, and I need the button to be disabled until the user clicks "I have read and agree to the terms of use. You can help me?

  • With Javascript neat? Got any HTML for example?

1 answer

2


Just wear the event change of checkbox to set the property value disabled button.

const checkbox = document.querySelector('#chk');
const button = document.querySelector('#bt');

checkbox.addEventListener('change', (e) => button.disabled = !e.target.checked);
<input type="checkbox" id="chk" /> Li e concordo com os termos
<br>
<button id="bt" disabled>Prosseguir</button>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.