Thanks guys! I deleted everything, and re-pasted everything from scratch. To my own shock, It works fine now I spent hours trying to figure it out, haha.
I had another small question related to the same code. I want to change the submit button's text, so that when It's disabled (checkbox unchecked) it says "Disabled" and when it's not disabled (checkbox checked) it says "Submit".
I'm a newbie at this, but I would assume the best way to go about this would be to alter the 'toggleSubmit()' function and add 'innerHTML' to it? I'm not really sure..
HTML:
<div class="one"><input type="checkbox" name="terms" id="terms" required> I agree to the terms, whatever they are.</div>
<div class="one1"><input type="submit" value"Submit" id="submit" ></div>
Javascript: (register.js)
function toggleSubmit() {
'use strict';
var submit = U.$('submit');
if (U.$('terms').checked) {
submit.disabled = false;
} else {
submit.disabled = true;
}
}
window.onload = function() {
'use strict';
U.addEvent(U.$('theForm'), 'submit', validateForm);
U.$('submit').disabled = true;
U.addEvent(U.$('terms'), 'change', toggleSubmit);
};
I hope that makes sense? This code is using utilities.js for the event listeners and variables etc.
Thanks again for the prompt replies!