This should be simple, but I'm missing something.
I am creating a form which asks users to accept terms and conditions and would like to disable the submit button until they click the checkbox, but can't get it to work (I'm not great at javascript)
Check it out here: http://jsfiddle.net/timothylarson/NEE3V/4/
HTML:
<form action="" method="get">
<p><input type="checkbox" value="checkbox" onchange="checked('accept')" /> I HAVE READ AND ACCEPT THE <a href="">TERMS & CONDITIONS</a></p>
<br/>
<input disabled="disabled" type="button" id="accept" class="button-grey" value="Submit" />
</form>
Javascript:
function checked(accept) {
var myLayer = document.getElementById(accept);
var input = myLayer.childNodes[0];
if (input.checked == true) {
myLayer.class = "button-orange";
myLayer.disabled = "";
} else {
myLayer.class = "button-grey";
myLayer.disabled = "disabled";
};
}
CSS:
p {
font-family:'Lato', sans-serif;
}
.button-orange {
text-shadow: 2px 2px #321;
float:left;
width: 100%;
border: #fbfbfb solid 4px;
border-radius: 5px;
box-shadow: 0px 0px 10px 3px #999;
cursor:pointer;
background-color: #E74700;
color:white;
font-size:24px;
padding-top:22px;
padding-bottom:22px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
margin-top:-4px;
font-weight:700;
}
.button-orange:hover {
background-color: red;
}
.button-grey {
text-shadow: 2px 2px #321;
float:left;
width: 100%;
border: #fbfbfb solid 4px;
border-radius: 5px;
box-shadow: 0px 0px 10px 3px #999;
cursor:pointer;
background-color: #999;
color:white;
font-size:24px;
padding-top:22px;
padding-bottom:22px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
margin-top:-4px;
font-weight:700;
}