// JavaScript Document

function validar(){
  
   var envio = document.getElementById("envio");
   var envioValue = envio.value;
   envio.disabled = true;
   envio.value="Enviando...";
  
   var sendForm = true;
   var msn = "Compruebe el formulario:\n\n";
  
  // nombre_usr 
  // pass_usr
		
  var valor = document.getElementById("usuario").value;
  if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
		msn += " - EL nombre de usuario es obligatorio\n";
		sendForm=false;
  }
  
  var valor = document.getElementById("password").value;
  if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
		msn += " - EL password es obligatorio\n";
		sendForm=false;
  }
  
  var valor = document.getElementById("re_password").value;
  if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
		msn += " - Debe repetir el password\n";
		sendForm=false;
  }
  
  
  var valor = document.getElementById("nombre").value;
  if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
		msn += " - EL nombre es obligatorio\n";
		sendForm=false;
  }
  
  
  //email obligatorio sintaxis 
  var valor = document.getElementById("email").value;
  if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
	  	msn += " - Debe especificar un correo electrónico de contacto\n";
		sendForm=false;
  }else{
	  if( !(/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(valor)) ) {
			msn += " - La direccion de correo electronico no es correcta\n";
			sendForm=false;
		}
  }

  var valor = document.getElementById("poblacion").value;
  if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
		msn += " - La poblacion es obligatoria\n";
		sendForm=false;
  }
 

  
  if(sendForm==false){
	alert(msn);
	envio.disabled = false;
    envio.value= envioValue;
	return false;
  }	

	
}
