[CLOSED] Is there a way to give the DateField multiple sets of min/max dates?

  1. #1

    [CLOSED] Is there a way to give the DateField multiple sets of min/max dates?

    Hi,

    With a DateField, I can set a MinDate and MaxDate. With a NumberField, I can set a MinValue and Max Value. But from what I can see, there isn't a way to set a range of min/max values for these fields.

    So, as an example, it would be useful to use a DatePicker to allow picking values from from between Jan 1 and Feb 28 OR Oct 1 and Nov 30. The calendar UI would then automatically enable/disable the correct range of dates. But I can't see a way to do this. Is it possible?

    From what I can see, for a NumberField, I might be able to set a custom Validator function to be invoked, but the challenge with the DateField is how to limit input from the picker in the first place and get it to grey out/disable the correct ranges?

    I've looked around a bit to see how other widget libraries deal with this, including even WinForms DateTimePicker etc, and they all seem to offer a single Min and Max approach, so I am assuming this is a very edge case scenario...

    Thanks!
    Last edited by Daniil; Sep 04, 2010 at 5:28 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You can configure the Validator function and run custom logic as required.

    Example

    <ext:TextField ID="TextField1" runat="server" Validator="function (val) { return val.length < 5; }" />
    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    Here's a link to the Validator property in the docs, see

    http://dev.sencha.com/deploy/dev/doc...mber=validator

    Hope this helps.
    Geoffrey McGill
    Founder
  4. #4
    Thanks Geoffery,

    Yes, I too noted the use of the Validator for things like the numeric scenario, but my particular issue was with the DateField (sorry for not wording my issue more clearly)

    The Validator is certainly an option but from a usability perspective it is "too late". That is, I somehow want to being able to give the DateField multiple min / max combinations (e.g. { min of jan 1 , max of feb 1} and { min of August 1, max of October 1} ) so that we can prevent the user from picking an out of bounds date in the first place (such as Mar 1 in the above example).

    If Ext JS doesn't actually have this feature (and most other web or desktop widgets I researched didn't seem to, either), then maybe that is fair enough, and for now the workaround is to use a custom Validator without explicit Min and Max...
  5. #5
    Hi Anup,

    Maybe the DisabledDates property could work for your scenario, see

    http://dev.sencha.com/deploy/dev/doc...=disabledDates

    Hope this helps.
    Geoffrey McGill
    Founder
  6. #6
    Absolutely fantastic!

    I don't know how I missed that -- I was looking at that same document too (though didn't think of inverting the solution...! Very nice) :o

    I'll have to try that out next week so can't confirm 100% just yet and it may take a small bit of effort to generate that kind of array from the kind of data I have, but I think it will work.

Similar Threads

  1. [CLOSED] Styling dates in DateField control
    By rmelancon in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Jan 27, 2012, 1:15 PM
  2. [CLOSED] Disabling dates in DateField
    By daneel in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 07, 2011, 12:01 PM
  3. [CLOSED] Select multiple dates in a datepicker
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 08, 2010, 4:31 PM
  4. [CLOSED] Disable specific dates and ranges in the DateField control
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 23, 2010, 5:56 PM
  5. [CLOSED] [1.0] DateField give "this.trigger is undefined"
    By rcaunt in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 16, 2010, 1:46 PM

Posting Permissions