[CLOSED] Invalid date and hour with pt-BR format

  1. #1

    [CLOSED] Invalid date and hour with pt-BR format

    Hi!

    In my application I use location pr-BR. I noticed that the DateField and TimeField components are exhibiting different behaviors to validate the entered value.

    Below an example of how I'm using the components:

    <%@ Page Language="C#" %>
      
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    </script>
     
    <!DOCTYPE html>
     
    <html>
    <head id="Head1" runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form id="Form1" runat="server" style="margin: 20px;">
            <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="pt-BR" />
            <ext:DateField ID="DateField" runat="server" FieldLabel="Data (30/04/2014 - dd/mm/yyyy) " LabelWidth="200"/>
            <ext:TimeField ID="TimeField" runat="server" FieldLabel="Hora (13:47 - hh:mm) " LabelWidth="200"/>
        </form>
    </body>
    </html>


    For example, in the date field inform "30042014" and the component is marked as invalid. If I inform "04302014" the field is validated and the value displayed to the user is "30/04/2014". The user in Brazil is not used to inform "mm / dd / yyyy". How do I change this behavior?

    Something similar happens with the field of time. If I inform "157", the value displayed is "01:57". If I inform "1200", the value displayed is "12:00". If I inform "1347", the field is marked as invalid. How do I change this behavior?

    Thanks!

    Ermanni
    Attached Thumbnails Click image for larger version. 

Name:	DateTime.PNG 
Views:	70 
Size:	2.9 KB 
ID:	10081  
    Last edited by Daniil; May 06, 2014 at 6:51 AM. Reason: [CLOSED]
  2. #2
    Quote Originally Posted by ermanni.info View Post
    The user in Brazil is not used to inform "mm / dd / yyyy". How do I change this behavior?
    Does setting the .Format property with the expected format solve the issue? There is also the .AltFormats property to pass an array of expected formats.
    Geoffrey McGill
    Founder
  3. #3
    Hi!

    Attributed format for DateField and nothing changed. Where do you find references for valid formats that are supported by the component?

    <ext:DateField ID="DateField" runat="server" FieldLabel="Data (30/04/2014 - dd/mm/yyyy) " LabelWidth="200" Format="dd/MM/yyyy"/>
    Researched here: http://docs.sencha.com/extjs/4.2.1/#...xt.util.Format, but no list of formats and meanings for each character!.

    You can perform this type of configuration in web.config, valid for the entire application?

    And to the field TimeField?

    Thanks!

    Ermanni
  4. #4
    Hello,

    For me, setting .AltFormats parses your input data correctly.
    Geoffrey McGill
    Founder
  5. #5
    Thank you!

    Worked using AltFormats. Now a question: at what address to find the meaning of expressions AltFormats? For example: what does the "g" for Time or "j" to Date? Minutes are represented by "i?"

    And how to perform this configuration in web.config is possible? Or otherwise?

    Thanks!

    Ermanni
  6. #6
    Quote Originally Posted by ermanni.info View Post
    Worked using AltFormats. Now a question: at what address to find the meaning of expressions AltFormats? For example: what does the "g" for Time or "j" to Date? Minutes are represented by "i?"
    Please see:
    http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Date

    Quote Originally Posted by ermanni.info View Post
    And how to perform this configuration in web.config is possible? Or otherwise?
    Do you mean setting up AltFormats globally? Unfortunately, there is no such a possibility.
  7. #7
    Hello Daniil,

    Thanks for the reference. It explained a lot.

    In DateField.AltFormats informed "dmY" but when I inform "01052014" field is marked as invalid. If I inform "1052014" field is valid (01/05/2014). In the referenced documentation is indicating that "d" represents the day of the two-digit month (leading zeros).

    What can it be?

    Thanks!

    Ermanni
  8. #8
    A DateField's AltFormats should be set up using .NET date format string.

Similar Threads

  1. Replies: 8
    Last Post: May 20, 2013, 4:01 AM
  2. Replies: 3
    Last Post: May 09, 2012, 4:28 PM
  3. Replies: 1
    Last Post: Apr 13, 2012, 1:52 PM
  4. Replies: 4
    Last Post: Jun 30, 2011, 3:30 PM
  5. [CLOSED] How to Set Date Format in a Coolite Date Field
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 02, 2010, 8:47 AM

Tags for this Thread

Posting Permissions