function orderSubmit(type) 
{
if (type == 'contrib') {
 if (!checkRequired() )
   {	
  document.AddPupil.submit();
  return true;
   }
 else {
   return false;
   }
}
}


function checkRequired() {

if (document.AddPupil.YEARSTART.value > document.AddPupil.YEAREND.value)
{
document.AddPupil.YEARSTART.focus()
alert('You have entered your school years incorrectly.\n' +
'Please try again.');
return true;
}

if (!document.AddPupil.FULLNAME.value.length)
{
document.AddPupil.FULLNAME.focus()
alert('You have not filled out the necessary details.\n' +
'Please enter your full name.');
return true;
}

if (!document.AddPupil.CONTACTEMAIL.value.length)
{
document.AddPupil.CONTACTEMAIL.focus()
alert('You have not filled out the necessary details.\n' +
'Please enter your contact email address.');
return true;
}

if (document.AddPupil.CONTACTEMAIL.value.length)
{
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.AddPupil.CONTACTEMAIL.value)))
{
document.AddPupil.CONTACTEMAIL.focus()
alert('The format of your email address appears to be incorrect.\n\n' +
      'Could you please carefully check to make sure that you have\n' +
      'entered the email address in the \'Contact email\' field correctly.')
return true;
}
}

if (!document.AddPupil.CONTRIB.value.length)
{
document.AddPupil.CONTRIB.focus()
alert('You have not filled out the necessary details.\n' +
'Please enter your contribution.');
return true;
}

else 
{
return false;
}

}
