PDA

View Full Version : Disable day selection in Date Picker



parky128
17 Mar 2011, 4:58 AM
Is it possible to configure the date picker to only allow selection of the month and year?

hpet
17 Mar 2011, 6:51 AM
You can disable days by putting disabledDays: [0,1,2,3,4,5,6] in your datefield conf.
This basicly disables all week days.

parky128
17 Mar 2011, 6:56 AM
OK, whilst that disables the days you can't actually select a date to display in the input field. So the selected date never actually changes.

hpet
17 Mar 2011, 7:05 AM
What are you trying to accomplish?
What would you like to be displayed in a date field (except date)? ...what would the day be once you select year/month?

Maybe you should take some other aproach (then datefield), like with a year/month combo?

parky128
17 Mar 2011, 7:08 AM
The day needs to always be the first day of the selected month\year so '01' in terms of the date part.

I could take the combo approach like you say but it would be nice to use the date picker if possible for this.

hpet
17 Mar 2011, 7:23 AM
By design it closes when day is selected, which kind of makes sense.

How will it behave when month is selected / or year. Two values to select from... so what will trigger picker to go away?

Maybe you could allow user to user datefield as normal, but hook into change event and set day back to 01 (whenever user selects and other value)

hpet
17 Mar 2011, 7:51 AM
or, maybe you can make some use of regexp config option to disable all days except 1st of each month.

disabledDates: ['../02/..','../03/..','../04/..','../05/..'] ... fill in up to 31st.

This would disable all days except 01 of each year/month, so when user selects year/month she must also select 1st, which normaly collapses the picker and sets the field value.