from pyscript import document def binair(event): invoer = document.getElementById("binair").value.strip() antwoord = document.getElementById("antwoord") if invoer == "": antwoord.innerText = "Vul eerst een binair getal in." return if not all(c in "01" for c in invoer): antwoord.innerText = "Ongeldige invoer: gebruik alleen 0 en 1." return uitkomst = int(invoer, 2) antwoord.innerText = f"Decimaal: {uitkomst}"