I'm doing an assignment with JavaScript and I have to make a quiz. My problem is I'm using the HTML 5 "required attribute" on my radio buttons. The problem is when I use an onclick event for the submit button it disregards the required attribute and executes the function to display a new question/choices. So if the radio buttons aren't selected it still performs the onclick event.
I'd like it so the required attribute checks if the radio buttons are checked before the onclick event.
I'm just not sure how to do this.
I display my radio buttons like this
var radio = document.createElement("input");
radio.type = "radio";
radio.id = i;
radio.value = i;
radio.name = "option";
radio.required = true;
Here is my JsFiddle: http://jsfiddle.net/VodkaTonic/4FJmU/