Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Validation error message is not displaying if user enter wrong date.

    Hi,
    We are using Smart Gwt-4.1p (23rd May 2014)
    Browser: IE10, 11, Google Chrome:37.0.2062.124 m

    Please find the attached code for your reference.

    Issue : If user enter the the invalid date (invalid digit) for DateItem date is getting converted to corresponding date.
    Ex : 02/25/20154456677 is displaying as 01/01/1970
    Expected behavior : It should display message as invalid date.

    I am using DateUtil for localization issue like /(slash) is converted to .(dot) in german language.

    Please guide me if any solution is available to display error message using date util.

    Thanks.
    Attached Files

    #2
    You probably want DateItem.setEnforceDate(true)

    Comment


      #3
      Yes, But DateItem.setEnforceDate(true) already handle but not working.You can check my code for your reference.

      Comment


        #4
        If you prefer that the user is informed of a validation error instead of auto-correction of the date to the most likely thing the user was trying to input:

        1. set enforceDate(false)

        2. fix your parser so that it does not just return today's date if it can't parse the date (as it currently does)

        Comment


          #5
          I set the properities setEnforceDate(false).
          In parser it is going to try block and returning converted corresponding date. I am getting same behavior.

          Comment


            #6
            We're not following what you think is a framework bug here.

            You have installed a parser that will return "currentDate" which contains the value "new Date()" if the user inputs something that can't be parsed as a date.

            So that's why you get the behavior you do. Just fix your parser, or get rid of it entirely, since it's actually just worse than what the framework will do by default.

            Comment


              #7
              Thanks for your reply.
              1. I observe that because of below code invalid date is converted to corresponding date.
              DateTimeFormat format = DateTimeFormat.getFormat(DATE_FORMAT);
              return format.parse(dateString);

              2. But if i am not using below code I am getting issue in german language.If user enter wrong date again enter correct date then error message is still displaying. In other language it is working fine.

              DateUtil.setDateParser(new DateParser()
              {
              public Date parse(String dateString)
              {
              try{
              if(dateString != null){
              final DateTimeFormat format = DateTimeFormat.getFormat(DATE_FORMAT);
              return format.parse(dateString);
              }
              }catch(Exception e){
              e.printStackTrace();
              }
              return null;
              }
              });

              Comment


                #8
                We do not observe such a problem with default settings in the German locale.

                If you think there's a framework problem here, try running your code, without any attempt to change default settings on DateUtil, in the German locale, in an unmodified SDK.

                If you still experience a problem in this scenario, show your complete code, and describe in detail how exactly the problem can be reproduced.

                Be exact: do not just say "enter wrong date again enter correct date" or similar wording - describe how focus leaves and re-enters the field (if it does so via click, keystroke, etc), and please make an attempt to use punctuation for clarity.

                Comment


                  #9
                  Thank you for reply.

                  Comment

                  Working...
                  X