javascript - jquery Check the year of a datepicker -


i'm using datepicker jqueryui in form. want validate year of birth. means user can't put in year higher 1998 (he/she must 18 years old). how can check if value isn't higher 1998? i've far.

<input type="text" id="birthyear" required><br />

$(function(){     $('#birthyear').datepicker({         mindate: new date(1900,1-1,1),         defaultdate: new date(1991,1-1,1),         changeyear: true,         yearrange: '-110:-18'     }); }); 

you can date object datepicker using getdate:

var date = $("#birthyear").datepicker("getdate"); 

from there can year:

var year = date.getfullyear(); 

if want make sure user @ least 18 years old, might want check more year: you'll want make sure today's date after 18th birthday.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -