I am trying to add a function, or additional JavaScript to the existing function for a confirmation. I will need a confirmation box once the submit button is clicked saying,
Set your radio buttons' values like this:
: GCSE
: A2
: AS
Then use this script in your function to validate form or make it a function and call it from your function validateForm:
var checked = null;
var inputs = document.getElementsByName('examtype');
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].checked) {
checked = inputs[i];
break;
}
}
if(checked==null)
{
alert('Please choose an option');
return false;
}
else{
return confirm('You have chosen '+checked.value+' is this correct?');
}
- 热议问题