/** * checkVotes * form: the form to validate * * Validate user-entered vote selection via the given form. * Submits the form if all three choices have been selected, and the user has agreed to the Terms of Voting */ function checkVotes(form) { var firstPlace, secondPlace, thirdPlace; // get selected first, second and third place choices from the form firstPlace = getSelectedRadioButtonValue( form.firstPlace ); secondPlace = getSelectedRadioButtonValue( form.secondPlace ); thirdPlace = getSelectedRadioButtonValue( form.thirdPlace ); // verify that a selection was made for each of the first, second and third places if( firstPlace == null ) errorBox.appendContent( "err_firstPlace", "You must select your choice for First Place." ); else errorBox.eraseError( "err_firstPlace" ); if( secondPlace == null ) errorBox.appendContent( "err_secondPlace", "You must select your choice for Second Place." ); else errorBox.eraseError( "err_secondPlace" ); if( thirdPlace == null ) errorBox.appendContent( "err_thirdPlace", "You must select your choice for Third Place." ); else errorBox.eraseError( "err_thirdPlace" ); // verify that the user has agreed to the Terms of Voting if( ! form.votingTermsAgreement.checked ) errorBox.appendContent( "agreement", "You must agree to the Terms of Voting." ); else errorBox.eraseError( "agreement" ); if( errorBox.isEmpty() ) form.submit(); else { errorBox.setVisible( true ); scroll(0,0); } } function getSelectedRadioButtonValue(radioButtonSet) { for(i=0; i