﻿function EsClaveValida(Elemento)
{
    var LaClave = Elemento.value;
     var filter= /^\w+([\.-]?\w+)*$/
    if (LaClave.length == 0 ) return true;
    if (filter.test(LaClave))
        return true;
    else
    {
        alert("Ingrese una contraseña válida!");
        Elemento.focus();  
        Elemento.select();  
        return false;
    }
}

function RepetirClave(Elemento1,Elemento2)
{
    var Caja = document.getElementById(Elemento2)    
    var LaClave1 = Elemento1.value;
    var LaClave2 = Caja.value;
    if ( LaClave1 == LaClave2 )
        return true;
    else
    {
        alert("No Repitió la clave Correctamente!");
        Elemento1.focus();
        Elemento1.select();
        return false;
    }
}

function EsUnEmail(Elemento)
{
    var ElMail = Elemento.value;
    /*/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;*/
    var filter= /^[a-z0-9]+[a-z0-9\.\-_]*[a-z0-9]+@[a-z0-9]+[\.\-_]*[a-z0-9]+\.[a-z]{2,4}$/
    if (ElMail.length == 0 ) return true;
    if (filter.test(ElMail))
        return true;
    else
    {
        alert("Ingrese una dirección de correo válida!");
        Elemento.focus();    
        return false;
    }
}

function RepetirEmail(Elemento1,Elemento2)
{
    var Caja = document.getElementById(Elemento2)    
    var ElMail1 = Elemento1.value;
    var ElMail2 = Caja.value;
    if ( ElMail1 == ElMail2 )
        return true;
    else
    {
        alert("No Repitió el Email Correctamente!");
        Elemento1.focus();
        Elemento1.select();
        return false;
    }
}

function FechaValida(dateA,anio2)
{
   var anio1 =  dateA.value.substr(dateA.value.length-4,dateA.value.length )  
   if ( anio1 < anio2)    
      return true; 
   else 
    alert("No Es una Fecha válida!");
    Elemento.focus();
    return false;
}

