Reputation: 7235
Does anyone have any idea's how to prevent a user picking a future date (greater than current date) on a datepicker field?
I know I can validate easily enough after the user clicks the done button on the picker and show them an alert message telling them they cannot pick a future date.
But it would be nice if there was some way to actually prevent the selection in the first place, such as disabling some of the slot values from selection. I'm not so sure this can be done, maybe validation is the only way?
Upvotes: 0
Views: 1193
Reputation: 1014
As I dont have enough reputation so I need to add my comments as an answer.
You have two ways to do this.
2nd option is a bit complex but worth it if this feature is most important.
Upvotes: 1
Reputation: 8954
You can at the very least limit the yearFrom
and yearTo
this is however only available as a documented config in the Ext.picker.Date
class which is actually the underlying class that gets called when creating an Ext.field.DatePicker
instance.
You can set options for the Ext.picker.Date
by passing in the options to the picker
property of the field
http://docs-origin.sencha.com/touch/2.4/2.4.1-apidocs/#!/api/Ext.field.DatePicker-cfg-picker
e.g.
Ext.create('Ext.form.Panel', {
fullscreen: true,
items: [{
xtype: 'fieldset',
items: [{
xtype: 'datepickerfield',
label: 'Birthday',
name: 'birthday',
value: new Date(),
picker:{
yearFrom:2000,
yearTo:2020
}
}]
}]
});
Upvotes: 0