O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting up available date ranges in Date fields

When using Date fields we will often want to restrict the dates that a user can pick from.

In this recipe we will explain how to configure a Date field to only have a specific range of dates available for selection and how to extend this functionality with advanced date disabling.

How to do it...

  1. First of all we create a very simple Date field and render it to the document's body.
    Ext.create('Ext.form.field.Date', {
        fieldLabel: 'Pick a Date',
    
        value: new Date(2011, 7, 8),
                            
        renderTo: Ext.getBody()
    });
  2. We can now introduce the minValue and maxValue configuration options to restrict the available dates.
    Ext.create('Ext.form.field.Date', { fieldLabel: 'Pick a Date', minValue: new Date(2011, 7, 5), maxValue: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required