﻿function validaSoloNumeros(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla == 8)
        return true;
    patron = /\d/;
    te = String.fromCharCode(tecla);
    return patron.test(te);
}

function validaDouble(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla == 8)
        return true;
    if (tecla == 46) {
        return String.fromCharCode(e);
    }
    else{
    patron = /^-{0,1}\d*\.{0,1}\d+$/;
    te = String.fromCharCode(tecla);
    }
    return patron.test(te);
}

function IsNumeric(input) {
    var RE = /^-{0,1}\d*\.{0,1}\d+$/;
    return (RE.test(input));
}
function IsNumericWCP(input) {
    var RE = /^[0-9]+([\.|,][0-9]*)?$/;
    //var RE = /^\[0-9]+([\.|,][0-9]*)?$/;
    return (RE.test(input));
}

function ValidaURL(url) {
    var re = /^(http|ftp)(s)?:\/\/\w+(\.\w+)*(-\w+)?\.([a-z]{2,3}|info|mobi|aero|asia|name)(:\d{2,5})?(\/)?((\/).+)?$/;
    return re.test(url);
}

function ValidaEmail(email) {
    var re = /^[_A-Za-z0-9-]+(.[A-Za-z0-9_.]+)*@[A-Za-z0-9_]+(.[A-Za-z0-9_.]+)[A-za-z]$/;
    return re.test(email);
}

function valEmail(valor) {
    re = /^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if (!re.exec(valor)) {
        return false;
    } else {
        return true;
    }
}

function validarAlfanumeric(inField) {
    return true;
}

function ValidaPostalCode(CP) {
    var re = /^((^\d{5})|(^\d{5}-\d{4})|(^\d{9}$)|([a-zA-Z])\d([a-zA-Z])(.?)\d([a-zA-Z])\d)$/;
    return re.test(CP);
}