
function comprobar() 
{
	var f = document.getElementById("form1");
	var ok;
	ok = true;
	
	if ((ok)&&(f.nombre.value=="")) {
		alert("Introduzca correctamente el nombre");
		ok = false;
		f.nombre.focus();
	}
	if ((ok)&&(f.email.value=="")) {
		alert("Introduzca correctamente el email");
		ok = false;
		f.email.focus();
	}
	if ((ok)&&(formatoEmail(f.email.value) == false))
	{
		alert("El email no es válido");
		ok = false;
		f.email.focus();
	}
	if ((ok)&&(f.telefono.value=="")) {
		alert("Introduzca correctamente el teléfono ");
		ok = false;
		f.telefono.focus();
	}
	
	return ok;
}

function borrar() 
{
	var f = document.getElementById("form1");

	f.reset();
}

function enviar() 
{
	var f = document.getElementById("form1");
	
	if (comprobar()) {
		f.submit();
	}		
}


function formatoEmail(valor) {
		if (valor.length>0){
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){
				return (true);
			}
			else{
				return (false);
			}
		}else return (true);
	}
