[CLOSED] DateField validation and typing dates in any formats

  1. #1

    [CLOSED] DateField validation and typing dates in any formats

    Hello Everyone,

    I have a FormPanel that contains a number of DateFields.
    FormPanel sends data to a server where I deserialize it using Json.

    Clients want to type dates in three formats (yyyy-mm-dd, dd/mm/yyyy, dd-mm-yyyy) or select it from calendar.
    Can I validate dates on client and send to the server a valid dates or '1900-01-01' (for example)?

    Technically, I can write a javascript that grabs the data, validates it, transforms it and all the rest, but I am not sure that is the right way.

    Any suggestions (with examples)?

    Thank you.
    Last edited by Daniil; Oct 10, 2014 at 7:58 AM. Reason: [CLOSED]
  2. #2
    Hi @rbtceo,

    FormPanel sends data to a server where I deserialize it using Json.
    Please clarify how exactly you submit the data from client. Via a FormPanel's submit?
  3. #3
    Hi Daniil,

    I submit it on button click:
    button.DirectEvents.Click.ExtraParams.Add(new Parameter("controlValues",
                            "#{" + formPanelName + "}.getForm().getValues(false,false,false,true)", ParameterMode.Raw));
  4. #4
    This
    .getValues(false,false,false,true)
    calls fields' .getModelData() method.
    http://docs.sencha.com/extjs/4.2.1/#...d-getModelData

    You can change it. The examples demonstrates that (with the original getModelData method).

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var myGetModelData = function() {
                var me = this,
                    data = null;
    
                if (!me.disabled && !me.isFileUpload()) {
                    data = {};
                    data[me.getName()] = me.getValue();
                }
    
                return data;
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:FormPanel ID="FormPanel1" runat="server">
                <Items>
                    <ext:DateField ID="DateField1" runat="server">
                        <GetModelData Fn="myGetModelData" />
                    </ext:DateField>
                </Items>
            </ext:FormPanel>
            
            <ext:Button runat="server" Text="Get values" Handler="console.log(App.FormPanel1.getForm().getValues(false,false,false,true));" />
        </form>
    </body>
    </html>
  5. #5
    Hi Daniil,

    Nice solution.

    Thank you

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] How to disable typing on a DateField
    By hgouw in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 27, 2011, 11:21 PM
  3. [CLOSED] Disabling dates in DateField
    By daneel in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 07, 2011, 12:01 PM
  4. Replies: 5
    Last Post: Sep 03, 2010, 8:19 PM
  5. [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

Tags for this Thread

Posting Permissions