


function validarFormulario()
{

//document.getElementById('Nombre')
if (document.getElementById('Nombre').value=='') {
alert("El Nombre es un Dato obligatorio.");
document.getElementById('Nombre').select();
document.getElementById('Nombre').focus();
document.getElementById('tnombre').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('Nombre').value.length>15) {
alert("El Nombre no puede contener más de 15 caracteres");
document.getElementById('Nombre').select();
document.getElementById('Nombre').focus();
document.getElementById('tnombre').className='txt_formulario-ico-error';
 return (false);
}

if (document.getElementById('Apellido1').value=='') {
alert("El primer Apellido es un Dato obligatorio.");
document.getElementById('Apellido1').focus();
document.getElementById('Apellido1').focus();
document.getElementById('tApellido1').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('Apellido1').value.length>20) {
alert("El primer Apellido no puede contener más de 20 caracteres");
document.getElementById('Apellido1').select();
document.getElementById('Apellido1').focus();
document.getElementById('tApellido1').className='txt_formulario-ico-error';
 return (false);
}
/*if (document.getElementById('Apellido2').value.length>20) {
alert("El segundo Apellido no puede contener más de 20 caracteres");
document.getElementById('Apellido2').select();
document.getElementById('Apellido2').focus();
document.getElementById('Apellido2').className='txt_formulario-ico-error';
 return (false);
}

if (document.getElementById('ndia').value=='0') {
alert("El dia de la Fecha de nacimiento es un Dato obligatorio.");
document.getElementById('ndia').focus();
document.getElementById('tndia').className='txt_formulario-ico-error';
 return (false);
}

if (document.getElementById('nmes').value=='a') {
alert("El mes de la Fecha de nacimiento es un Dato obligatorio.");
document.getElementById('nmes').focus();
document.getElementById('tndia').className='txt_formulario-ico-error';
 return (false);
}

if (document.getElementById('nanyo').value=='0') {
alert("El año de la Fecha de nacimiento es un Dato obligatorio.");
document.getElementById('nanyo').focus();
document.getElementById('tndia').className='txt_formulario-ico-error';
 return (false);
}


if (document.getElementById('Nacionalidad').value=='') {
alert("El país de nacimiento es un Dato obligatorio.");
document.getElementById('Nacionalidad').select();
document.getElementById('Nacionalidad').focus();
document.getElementById('tNacionalidad').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('Nacionalidad').value=='999') {
alert("El país de nacimiento es un Dato obligatorio.");
document.getElementById('Nacionalidad').select();
document.getElementById('Nacionalidad').focus();
document.getElementById('tNacionalidad').className='txt_formulario-ico-error';
 return (false);
}
//if (document.contactosexo').value=='') {
//alert("El Sexo es un Dato obligatorio.");
//document.getElementById('sexo').focus();
// return (false);
//}
*/
if (document.getElementById('Email1').value=='') {
alert("La Dirección de correo electrónico es un Dato obligatorio.");
document.getElementById('Email1').select();
document.getElementById('Email1').focus();
document.getElementById('tEmail1').className='txt_formulario-ico-error';
 return (false);
} 
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('Email1').value)){
  
 
  } else {
   alert("La dirección de correo electrónico es incorrecta.");
   document.getElementById('Email1').select();
   document.getElementById('Email1').focus();
   document.getElementById('tEmail1').className='txt_formulario-ico-error';
   return (false);
  }
if (document.getElementById('Email1').value.length>40) {
alert("El Email no puede contener más de 40 caracteres");
document.getElementById('Email1').select();
document.getElementById('Email1').focus();
document.getElementById('tEmail1').className='txt_formulario-ico-error';
 return (false);
}  
  
if (document.getElementById('Telefono1').value=='') {
alert("El Teléfono es un Dato obligatorio.");
document.getElementById('Telefono1').select();
document.getElementById('Telefono1').focus();
document.getElementById('tTelefono1').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('Telefono1').value.length>25) {
alert("El primer Teléfono no puede contener más de 25 caracteres");
document.getElementById('Telefono1').select();
document.getElementById('Telefono1').focus();
document.getElementById('tTelefono1').className='txt_formulario-ico-error';
 return (false);
}  
/*if (document.getElementById('Telefono2').value.length>25) {
alert("El segundo Teléfono no puede contener más de 25 caracteres");
document.getElementById('Telefono2').select();
document.getElementById('Telefono2').focus();
document.getElementById('tTelefono2').className='txt_formulario-ico-error';
 return (false);
} 

if (document.getElementById('Domicilio').value=='') {
alert("La dirección es un Dato obligatorio.");
document.getElementById('Domicilio').select();
document.getElementById('Domicilio').focus();
document.getElementById('tDomicilio').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('Domicilio').value.length>30) {
alert("La dirección no puede contener más de 30 caracteres");
document.getElementById('Domicilio').select();
document.getElementById('Domicilio').focus();
document.getElementById('tDomicilio').className='txt_formulario-ico-error';
 return (false);
}  

if (document.getElementById('Numero').value=='') {
alert("El Número es un Dato obligatorio.");
document.getElementById('Numero').select();
document.getElementById('Numero').focus();
document.getElementById('tNumero').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('Numero').value.length>4) {
alert("El Número no puede contener más de 4 caracteres");
document.getElementById('Numero').select();
document.getElementById('Numero').focus();
document.getElementById('tNumero').className='txt_formulario-ico-error';
 return (false);
}  

if (document.getElementById('Localidad').value=='') {
alert("La localidad es un Dato obligatorio !");
document.getElementById('Localidad').select();
document.getElementById('Localidad').focus();
document.getElementById('tLocalidad').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('Localidad').value.length>30) {
alert("La localidad no puede contener más de 30 caracteres");
document.getElementById('Localidad').select();
document.getElementById('Localidad').focus();
document.getElementById('tLocalidad').className='txt_formulario-ico-error';
 return (false);
}
*/ 
if (document.getElementById('Cp').value=='') {
alert("El Código postal es un Dato obligatorio.");
document.getElementById('Cp').select();
document.getElementById('Cp').focus();
document.getElementById('tCp').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('Cp').value.length>5) {
alert("El Código postal no puede contener más de 5 caracteres");
document.getElementById('Cp').select();
document.getElementById('Cp').focus();
document.getElementById('tCp').className='txt_formulario-ico-error';
 return (false);
}  


if (document.getElementById('Provincia2').value.length>20) {
alert("La Provincia no puede contener más de 20 caracteres");
document.getElementById('Provincia2').select();
document.getElementById('Provincia2').focus();
document.getElementById('tProvincia2').className='txt_formulario-ico-error';
 return (false);
}  


if (document.getElementById('Provincia2').value=="" ) {
if (document.getElementById('Provincia').value=='999') {
alert("La Provincia es un Dato obligatorio.");
document.getElementById('tProvincia').className='txt_formulario-ico-error';

 return (false);
}
}


if (document.getElementById('pais').value=='') {
alert("El país es un Dato obligatorio.");
document.getElementById('pais').select();
document.getElementById('pais').focus();
document.getElementById('tpais').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('pais').value=='000' && document.getElementById('Cp').value.length!=5) {
alert("El Código Postal no es correcto.");
document.getElementById('Cp').select();
document.getElementById('Cp').focus();
document.getElementById('tCp').className='txt_formulario-ico-error';
 return (false);
}

if (document.getElementById('pais').value=='000' && document.getElementById('Provincia').value=='999') {
alert("Debe seleccionar una Provincia");
//document.getElementById('Provincia').select();
document.getElementById('Provincia').focus();
document.getElementById('Provincia').className='txt_formulario-ico-error';
 return (false);
}




if (document.getElementById('pais').value=='001'){document.getElementById('cp').value='98000';}

if (document.getElementById('pais').value=='999') {
alert("El país es un Dato obligatorio.");
document.getElementById('pais').select();
document.getElementById('pais').focus();
document.getElementById('tpais').className='txt_formulario-ico-error';
 return (false);
}
if (document.getElementById('aceptolopd').checked==false) {
alert("Tiene que aceptar el aviso legal.");
document.getElementById('aceptolopd').focus();
 return (false);
}


     document.getElementById('interesado').submit();
}