
function validaEnteroPositivo(value, len) {
  /*
    Funcion para validar números enteros positivos
    Esta regresa:
      -1    Si la longitud es menor a la solicitada
       0    Si tiene se encontró algún carater no numérico
       1    Si es número entero y mayor o igual a longitud solicitada

    Parametros:
      value	Número o Caracter. Valor a procesar.
      len	Numérico. Longitud mínima requerida. Si viene
			  con valor igual a cero(0) no se
			  efectua validación de longitud.
  */
  var num = new String(value);
  var numeros = new String("0123456789");
  var lengthMin = parseInt(len,10);

  num = num.replace(/(^\s*)|(\s*$)/g, ""); // trim

  // Validar solo caracteres numéricos
  if ( num.search(/\D/g) != -1) return (0);

  // Si la longitud es menor que la pedida salir
  if ( lengthMin > 0 ) if ( num.length < lengthMin ) return (-1)

  return(1);
} // Fin de: esEnteroPositivo



function ChecarBlanco(Control,nombre)
{
	if(Control)
	{
		if(Control.value!="" && Control.value!=null)
		{
			return(true)
		}
		else
		{
			alert("El campo " + nombre + " es requerido" )
			Control.focus();
			return(false);
		}
	
	}
	else
	{
		alert("El objeto no es valido o es nulo")
		return(false);
	}
	
}


function ValidarNumero(Control,nombre)
{	
	
	if(Control)
	{	
		if(isNaN(Control.value))
		{
			alert("El campo " + nombre + " debe ser numerico" )
			Control.focus();
			return(false);
			
			
		}
		else
		{
			return(true)
		}
	}
	
	else
	{
		alert("El objeto no es valido o es nulo")
		return(false);
	}
}

function ValidarEMail(Control,nombre) 
{ 
		var strEmail=Control.value

			var msgError="La entrada no es un E-mail en el campo:" + nombre
 
             var at="@" 

             var dot="." 

              var lat=strEmail.indexOf(at) 

              var lstr=strEmail.length 

             ldot=strEmail.indexOf(dot) 

             if (strEmail.indexOf(at)==-1)

             {
                       alert(msgError) 
						Control.focus();
                        return false 
                }

              if (strEmail.indexOf(at)==-1 || strEmail.indexOf(at)==0 || strEmail.indexOf(at)==lstr)

             {

                 alert(msgError) 
                 Control.focus();

                return false 

                } 

             if (strEmail.indexOf(dot)==-1 || strEmail.indexOf(dot)==0 || strEmail.indexOf(dot)==lstr)

              {

                       alert(msgError)
                       Control.focus();

                          return false

                  } 

                if (strEmail.indexOf(at,(lat+1))!=-1)

              {

                        alert(msgError) 
                        Control.focus();

                        return false

                  } 

             if (strEmail.substring(lat-1,lat)==dot || strEmail.substring(lat+1,lat+2)==dot)

            { 

                    alert(msgError)
                    Control.focus();

                   return false 

               } 

          if (strEmail.indexOf(dot,(lat+2))==-1)

                    { 

                            alert(msgError)
                            Control.focus();

                             return false 

                    }

                if (strEmail.indexOf(" ")!=-1)

         { 

                 alert(msgError)
                 Control.focus();

                   return false
              }

        return true

 } 



function ValidaContra(pass)
{

	var n;
	n=pass.value.length;
	//alert(n);
	
	if (n<8 || n>15){ 
		
	alert("Las contrasenas no deben ser menores de 8 caracteres, o mayores de 15 caracteres")
	pass.focus();
	return(false) }
	else
	{
		return(true)
	}


}
 

