Hey,
I am trying to work out a way to validate the following page: http://www.loumolloy.com/testing.php
On page load a survey will appear, you will see “Step1…2…3” at the top. Now users should not be able to get to the next step unless they have filled in all the fields… In this case it is simply radio buttons for question 1 and 2.
I have put together the following function to validate the boxes but it does not work properly, if i select female i get the wrong error. It’s like it only validates correctly if i check the first radio button?
Anyway, this is the function:
function validate_page_1()
{
if(document.getElementById('input-1').checked != true)
{
alert('You missed out question 1.');
}
if(document.getElementById('input-2').checked != true) {
alert('You missed out question 2.');
} else {
document.getElementById('page-1').style.display='none';
document.getElementById('page-2').style.display='block';
}
}
If you view source on the page you will see that on this line:
<input type="submit" class="button-next right" name="btnnext" value="" onclick="validate_page_1()"/>
I trigger the validation, and it does pick it up but i don’t know why it’s not doing it properly…
Can anyone help?
Thanks again