[Solved] How to determine if the user is 18 years old and up using jquery?


Try this:

Jquery:

$('#datepicker').datepicker({
onSelect: function(value, ui) {
    var today = new Date(), 
        age = today.getFullYear() - ui.selectedYear;
    if(age >= 18)
        $('#age').text("User is 18 years old");
    else
        $('#age').text("User is 18 not years old");
},
maxDate: '+0d',
changeMonth: true,
changeYear: true,
yearRange: '-110:-30'

});

Html:

<input type="text" id="datepicker" />
<div id="age" />

5

solved How to determine if the user is 18 years old and up using jquery?