I am trying to sharpen my vanilla JavaScript skills a little bit. I am working on a form validator just for fun. Here is my code thus far:
var getParent = document.getElementById("myForm");
document.getElementById("submit").onclick = function(e) {
e.preventDefault();
var cache = !cache ? "Nothing has been selected" : cache;
for(i = 0; i < getParent.elements.method.length; i++) {
if(getParent.elements.method[i].checked) {
cache = getParent.elements.method[i].value;
}
}
getParent.submit();
}
As you can see, this just tests some radio buttons to see if they are checked or not. I am trying to use the .submit() function at the bottom to submit my form, but I am getting an error. Why is this code not submitting my form with .submit()??
Submitinstead ofsubmit. I wouldn't have expected OP to have found that question by Googling the error message, so it's sufficiently different.