// This is the function you would use to require certain fields to be filled in when submitting a form.
// In this case it is just the name and e-mail, but it can be applied to any other field.

function validate(form) {
	var e = form.elements, m = '';
	
	if(!e['first_name'].value) {
		m += '- First name is required.\n';
	}
	if(!e['last_name'].value) {
		m += '- Last name is required.\n';
	}
var str = e['email'].value;
	var reg = new RegExp("([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})");
			
	if (!reg.test(str))
	{
		m += '- Email Address is required and/or Email is not correct\n';
	}	
	if(!e['phone'].value) {
		m += '- Phone Number is required.\n';
	}
	if(m) {
		alert('The following error(s) occurred:\n\n' + m);
		return false;
	}
	return true;
}

// You would also need to make sure you have the onSubmit property declared within the <form> tag.
// For example: <form onSubmit="return validate(this)" method="post" action="process_contact.php">