I’ve got a form that is submitted using ajax. The problem is that although I’ve got it to check if everything else if filled out or not I can’t get it to check if the confirm button is checked or not. This is what I’ve got but it’s just not adding ‘error’ to the confirm-box div
I could be wrong, but I believe that “confirm” is a reserved word in JavaScript due to “confirm()”. Give it a different ID and name and see if that fixes it.
HTH,
UPDATE: Also, you are setting a variable called “confirm” to the value of the radio. If the radio isn’t checked, it doesn’t exist. Also, if there are two radio inputs named the same, you check which one is checked by comparing “radioName[0]” and “radioName[1]” checked status.
“radioName” is my pseudo-code, not an actual JS convention. If you give a variable name “terms_agree” the object (radio input) that is named “terms_agree”…
var terms_agree = document.formName.terms_agree; // or in jQuery, var terms_agree = $('#terms_agree');
// Again, “formName” is pseudo-code - use the actual form name in its place.
if(!terms_agree[0].checked && !terms_agree[1].checked){ // Exclamation point means "not"
.... error code..
}