Well, offhand what I see you're missing is an opening brace after your first if statement. However, you can make your code quite a bit more efficient by storing the form as a reference, a refactoring some of your variables out of existence.
Code:
function checkForm()
{
var f = document.forms["submitscore"];
if ( !f.forfeit.checked )
{
var r1h = parseFloat( f.r1h.value );
var r2h = parseFloat( f.r2h.value );
var r1a = parseFloat( f.r1a.value );
var r2a = parseFloat( f.r2a.value );
var totalScore = r1h + r2h + r1a + r2a; // already numbers, no need to run parseFloat on total
if ( totalScore != 24 )
{
alert('The Round 1 and Round 2 scores do not add up to an even 24 rounds.');
return false;
}
}
return true;
}
Bookmarks