[CLOSED] DateField validate problem with Vtype="daterange"

  1. #1

    [CLOSED] DateField validate problem with Vtype="daterange"

    I have the following problem with the DateField control, when I set up the property VType = "daterange" the validation of date format does not trip and travels to the server a malformed data. If I did not configure VType property validates the client-side data correctly. As might fix the problem?

    this is my example:

    income 'aaaaa' in the DateField and when it loses the focus does not show any error message

    this is my source code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="CooliteIssue.WebForm2" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    <script language="javascript" type="text/javascript">
        function resetDateFields(field1, field2) {
            field1.dateRangeMin = null;
            field2.dateRangeMax = null;
            field1.setMaxValue();
            field2.setMinValue();
            field1.reset();
            field2.reset();
        }
     
        function resetOneField(field1, field2, isMin) {
            field1[isMin ? "dateRangeMin" : "dateRangeMax"] = null;
            field2[isMin ? "setMaxValue" : "setMinValue"]();
            field1.reset();
        }
     
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <ext:ResourceManager ID="smManager" runat="server">
            </ext:ResourceManager>
            <ext:Panel ID="pnlGeneral" runat="server" Border="true" BodyStyle="padding:5px;">
                <Content>
                    <ext:FormPanel ID="frmGeneral" 
                        runat="server" 
                        MonitorPoll="500" 
                        MonitorValid="true" 
                        AutoWidth="true" 
                        PaddingSummary="8px 8px 0"
                        BodyStyle="padding:5px;"
                        Layout="Form">
                    <Items>
                        <ext:DateField 
                                ID="dpClosingDate" 
                                runat="server"
                                Vtype="daterange"
                                FieldLabel="Closing date"
                                Width="100" 
                                AllowBlank="false" ShowToday="false">  
                            <Listeners>
                                <Render Handler="this.endDateField = '#{dpPaymentDate}';" />
                                <Change Handler="if(Ext.isEmpty(this.getValue(), false)){resetOneField(#{dpClosingDate}, #{dpPaymentDate}, false);}" />
                            </Listeners>
                        </ext:DateField>
                        <ext:DateField 
                                ID="dpPaymentDate"
                                runat="server" 
                                Vtype="daterange"
                                FieldLabel="Payment date"
                                Width="100" AllowBlank="false" ShowToday="false">
                            <Listeners>
                                <Render Handler="this.startDateField = '#{dpClosingDate}';" />
                                <Change Handler="if(Ext.isEmpty(this.getValue(), false)){resetOneField(#{dpPaymentDate}, #{dpClosingDate}, true);}" />
                            </Listeners>
                        </ext:DateField>
                    </Items>
                </ext:FormPanel>
                </Content>
            </ext:Panel>
     
        </div>
        </form>
    </body>
    </html>
    Last edited by Daniil; Sep 30, 2010 at 8:08 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Thank you for the report.

    I think a fix will be committed soon in the SVN

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
        <ext:ResourcePlaceHolder runat="server" />
    
        <script type="text/javascript">
            Ext.apply(Ext.form.VTypes, {
                daterange: function(val, field) {
                    var date = field.parseDate(val);
    
                    if (!date) {
                        return true; //instead of 'return;' - it was breaking a validation process
                    }
    
                    if (field.startDateField && (!field.dateRangeMax || (date.getTime() != field.dateRangeMax.getTime()))) {
                        var start = Ext.getCmp(field.startDateField);
                        if (start) {
                            start.setMaxValue(date);
                            field.dateRangeMax = date;
                            start.validate();
                        }
                    } else if (field.endDateField && (!field.dateRangeMin || (date.getTime() != field.dateRangeMin.getTime()))) {
                        var end = Ext.getCmp(field.endDateField);
                        if (end) {
                            end.setMinValue(date);
                            field.dateRangeMin = date;
                            end.validate();
                        }
                    }
                    /*
                    * Always return true since we're only using this vtype to set the
                    * min/max allowed values (these are tested for after the vtype test)
                    */
                    return true;
                }
            });
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:FormPanel runat="server">
            <Items>
                <ext:DateField 
                    ID="DateField1" 
                    runat="server" 
                    Width="100" 
                    FieldLabel="To" 
                    Vtype="daterange"
                    EndDateField="DateField2" />
                <ext:DateField 
                    ID="DateField2" 
                    runat="server" 
                    Width="100" 
                    FieldLabel="From" 
                    Vtype="daterange"
                    StartDateField="DateField1" />
            </Items>
        </ext:FormPanel>
        </form>
    </body>
    </html>
  3. #3
    Thanks Daniil.
  4. #4
    The fix has been committed.
    Please update from the SVN.

Similar Threads

  1. TextBox wit AllowBlank="False" and VType
    By inaltec in forum 1.x Help
    Replies: 2
    Last Post: Jul 25, 2012, 4:42 PM
  2. Replies: 5
    Last Post: May 02, 2012, 5:37 PM
  3. [CLOSED] SelectBox: Problem with characters "<" and ">"
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 03, 2011, 6:43 AM
  4. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  5. [CLOSED] DateField with Vtype="daterange" error
    By turione in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 27, 2009, 5:39 PM

Posting Permissions