If someone need to calculate it, this is the code im using:
function esBiciesto(anio){
if ((anio % 4 == 0 && anio % 100 != 0) || (anio % 4 == 0 && anio % 100 == 0 && anio % 400 == 0)) {
return 1;
}else{
return 0;
}
}
function cantidadDiasPorMes(anio, mes) {
var arrayDiaMes = [[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]];
return arrayDiaMes[esBiciesto(anio)][mes - 1];
}
function calcularEdad(fecha){
//fecha HOY
var hoy = new Date();
var mesHoy = hoy.getMonth() + 1;
var diaHoy = hoy.getDate();
var anioHoy = hoy.getFullYear();
//fecha SELECCIONADA
var mesFecha = fecha.getMonth() + 1;
var diaFecha = fecha.getDate();
var anioFecha = fecha.getFullYear();
var anios = anioHoy - anioFecha;
var meses = mesHoy - mesFecha;;
var dias = diaHoy - diaFecha;;
if (dias < 0) {
meses--;
if ((mesFecha - 1) == 0) {
dias += cantidadDiasPorMes(anioFecha, 12);
} else {
dias += cantidadDiasPorMes(anioFecha, mesFecha - 1);
}
}
if (meses < 0) {
meses += 12;
anios--;
}
return anios;
}
And:
$("#FechaNacimiento").on('close', function(event){
$("#Edad").val(calcularEdad($("#FechaNacimiento").jqxDateTimeInput('getDate')));
});