<form name=formtest onsubmit="return checkInput()">
...
</form>
<script language="javascript">
function checkInput()
{
  for (var i=1; i <=40; i++)
  {
     var radios = document.all("question"+i), j;
     for (j=0; j < radios.length; j++)
     {
          if (radios[j].checked)
            break;
     }
     
     if (j == radios.length)
     {
         alert("you must select a choice in question " + i);
         return false;
     }
  }  return true;
}
</script>