سؤال

I have a DOB(Date of Birth) and DOJ(Date of Joining) fields in my application. I want to set the DOB DateField range from 1960 to todayDate-20 years. It means how can I set my DOB rangeEnd as (current year(2014) -20 years)?. And How can I set DOJ rangeEnd as (todayDate+7 days)?

هل كانت مفيدة؟

المحلول

About add range on date you can proceed in this way:

I suppose your DateField component calls DOB:

You can set a range with selectableRange property using rangeStart and rangeEnd properies, in this way:

this.DOB.selectableRange = {rangeStart:new Date(1960,01,01), rangeEnd: new Date()};

to accomplish your request you can do:

var today:Date = new Date();
var currentYear = today.fullYear;
var currentMonth = today.month;
var currentDay = today.date;
var start20yago:Date = new Date(currentYear - 20, 1, 1);

var after7Days:Date = today["date"] + 7;

this.DOB.selectableRange = {rangeStart:start20yago, rangeEnd: after7Days};
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top