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
Post a Comment