
function isValidEmail(string) {

	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}

function isValidInput(string) {
	
	if (string.length < 255 && string.length > 0)
		return true;
	else
		return false;
}

function clearFields(f){
	f.email.style.backgroundColor = 'ffffff';
	f.firstname.style.backgroundColor = 'ffffff';
	f.lastname.style.backgroundColor = 'ffffff';
	f.company.style.backgroundColor = 'ffffff';

}

function submitForm(f){
	
	clearFields(f);
	
	if(!isValidInput(f.firstname.value)){
		alert('Uw voornaam is niet ingevuld');
		f.firstname.focus();
		f.firstname.style.backgroundColor = 'ff6474';
	}else if(!isValidInput(f.lastname.value)){
		alert('Uw achternaam is niet ingevuld');
		f.lastname.focus();
		f.lastname.style.backgroundColor = 'ff6474';
	}else if(!isValidEmail(f.email.value)){
  		alert('Dit is geen geldig e-mailadres');
  		f.email.focus();
  		f.email.style.backgroundColor = 'ff6474';
 	}else if(!isValidInput(f.company.value)){
		alert('Uw bedrijfsnaam is niet ingevuld');
		f.company.focus();
		f.company.style.backgroundColor = 'ff6474';	
	}else{
		f.submit();
	}
}