[CLOSED] [#786] [3.2.0] DateRange validation

  1. #1

    [CLOSED] [#786] [3.2.0] DateRange validation

    On the following example https://examples3.ext.net/#/Form/Dat...From-To_Range/, field is validated and Min and Max values are updated on its KeyUp event. I remember that it was required but at this time, after some tests i think that it's not required anymore.

    Daniil, can you confirm that?

    In addition, it would be nice if it were done internally (if it's still required), as shown below:
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Multiple DateFields with DateRange Validation - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
        <script>
            Ext.form.field.Date.override({
                initComponent: function () {
                    this.callParent(arguments);
                    if (this.vtype == "daterange") {
                        this.on("keyup", function (item, event) {
                            var date = item.getValue();
                            if (Ext.isDate(date)) {
                                if (item.startDateField) {
                                    Ext.getCmp(item.startDateField).setMaxValue(date);
                                    item.dateRangeMax = date;
                                }
                                else if (item.endDateField) {
                                    Ext.getCmp(item.endDateField).setMinValue(date);
                                    item.dateRangeMin = date;
                                }
                                item.validate();
                            }
                        }, this);
                    }
                }
            });
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ScriptMode="Debug" Theme="Crisp" runat="server" />
            <ext:Window Width="350" Title="DateRange" Icon="Date" Closable="false" BodyPadding="5" Layout="Anchor" DefaultAnchor="100%" runat="server">
                <Items>
                    <ext:DateField ID="DateField1" Vtype="daterange" FieldLabel="From" EnableKeyEvents="true" runat="server">
                        <CustomConfig>
                            <ext:ConfigItem Name="endDateField" Value="DateField2" Mode="Value" />
                        </CustomConfig>
                    </ext:DateField>
                    <ext:DateField ID="DateField2" Vtype="daterange" FieldLabel="To" EnableKeyEvents="true" runat="server">
                        <CustomConfig>
                            <ext:ConfigItem Name="startDateField" Value="DateField1" Mode="Value" />
                        </CustomConfig>
                    </ext:DateField>
                </Items>
            </ext:Window>
        </form>
    </body>
    </html>
    Thanks in advance.
    Last edited by Daniil; Apr 15, 2015 at 5:04 PM. Reason: [CLOSED] [#786] [3.2.0]
  2. #2
    Hi Raphael,

    Look at this:)
    http://forums.ext.net/showthread.php?42791

    This time I found the original thread when that onKeyUp handler appears.
    http://forums.ext.net/showthread.php?17127

    I checked that scenario and can say that onKeyUp is still required.

    I like your idea of "hiding" those onKeyUp handler internally. Created an Issue.
    https://github.com/extnet/Ext.NET/issues/786

    As for your override, I am not sure why your KeyUp handler differs from the one in the example. It doesn't work as needed. Though, never mind.

    Also I think it is good to get rid of the requirement to set EnableKeyEvents as well.

    Done in the revision 6420 (trunk). It goes to 3.2.0.

    Thank you for the suggestion!
  3. #3
    Sometimes i forget. I open a lot of threads and it's hard to remember them all.

    As for your override, I am not sure why your KeyUp handler differs from the one in the example. It doesn't work as needed. Though, never mind.
    I tried to figure it out but unfortunately with no success. I added if (Ext.isDate(date)) (line 13) but it did not affect the result.

    Once again thank you Daniil.

Similar Threads

  1. Replies: 3
    Last Post: Feb 22, 2015, 3:29 PM
  2. [CLOSED] DateField with DateRange Validation
    By RCN in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 03, 2014, 11:30 AM
  3. Replies: 3
    Last Post: Feb 19, 2014, 12:04 PM
  4. [CLOSED] DateField daterange validation error
    By jeybonnet in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 15, 2012, 2:13 PM
  5. Replies: 3
    Last Post: Jul 11, 2011, 9:43 AM

Posting Permissions