I have a problem with a button attribute. It does not matter whether YES or NO is changed. I suspect the problem here is button.disabled
because it does not highlight the word "disabled".
window.onload = function()
{
var button = document.getElementsByName("button");
var regulamin = document.getElementsByName("accept");
//console.log(button);
for (var i = 0; i < regulamin.length; i++)
{
regulamin[i].onclick = function()
{
//alert(this.value === "true"); <-- here is OK
button.disabled = (this.value === "true"); <-- not OK
};
}
};
<form>
<div>
<label><input type="radio" name="accept" value="true" checked>NO</label>
<label><input type="radio" name="accept" value="false">YES</label>
</div>
<button type="submit" name="button" disabled>REGISTER</button>
</form>