﻿// JavaScript Document

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

function validaformulariosimple(){
    //valido el nombre
    if (document.getElementById("nombre").value.length==0){
       alert("Su nombre es obligatorio")
       document.form.nombre.focus()
       return 0;
    }
	 
     if (document.getElementById("email").value.length>0){
    	if (validarEmail(document.getElementById("email").value)==false){
			  alert("El email parece no ser correcto")
              document.form.email.focus();
              return 0;
			}
	 }
	
	 if (document.getElementById("email").value.length==0){
       alert("El email es obligatorio")
       document.form.email.focus()
       return 0;
	 }
	 
	 if (document.getElementById("telefono").value.length==0){
       alert("El teléfono es obligatorio")
       document.form.telefono.focus()
       return 0;
    }
	
	if (document.getElementById("legal").checked==false){
       alert("Por favor, confirme que ha leído y aceptado el aviso legal")
       document.form.legal.focus()
       return 0;
    }
	

   document.getElementById('form').submit(); 

} 
