Search code examples
extjsextjs6.2

ExtJS 6.2 Disable Dates Before Certain Date in datefield Form Field


I have a datefield and I'd like to be able to disable all dates in the date picker before a certain date using the format YYYY-MM-DD. Can this be done in an ExtJS datefield?


Solution

  • Sure, use the minValue property, like:

    Ext.create('Ext.form.Panel', {
    title: 'DateField Example',
    width: 300,
    bodyPadding: 10,
    renderTo: Ext.getBody(),
    items: [{
        xtype: 'datefield',
        fieldLabel: 'Select Date',
        name: 'date',
        // Set the minimum date using a date string in YYYY-MM-DD format
        minValue: Ext.Date.parse('2023-08-01', 'Y-m-d'),
        // Optional: Set a specific format for displaying the date
        format: 'Y-m-d',
        allowBlank: false
    }]
    

    });