0

Datebox changing date value

asked 2014-08-04 18:10:05 +0800

assimoco gravatar image assimoco
0

Sometimes dates inserted in Datebox Component are changed without any warning or error message. For example, working with a Datebox with lenient set to "false" and date format set to "yyyy/MM/dd", you get this output:

  • 0000/00/00 becomes 30/11/1999
  • 0001/11/30 becomes 2001/11/30
  • 0100/11/30 becomes 2100/11/30

We expected the system displayed error message in the first case and accepted the dates inserted without changing them in the other cases. Is there any way to fix it? Do you have any suggestion to manage it?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-08-09 16:19:49 +0800

Darksu gravatar image Darksu
1991 1 4

Hello assimoco,

It seems that the component is trying to auto correct the value

Could you please apply the following code in order to solve the issue...

Datebox box = new Datebox();    
box.setLenient( false ); 
box.setConstraint( "before 20380101" );

*Set the constraint to a desired value.

Furthremore you can check out the constraint section of the following url and use the no past constraint:

http://books.zkoss.org/wiki/ZKComponentReference/Input/Datebox

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2014-08-12 11:12:45 +0800

assimoco gravatar image assimoco
0

Hi Darksu, thanks for your answer!

My problem is I need to accept the dates "0001/11/30" and "0100/11/30" as valid.

I tried your suggestion about constraints with the following code:

<zk>
<hlayout>
    <space spacing="200px" />
    <vlayout>
        <separator spacing="200px" />
        <datebox id="datebox" cols="12" format="yyyy/MM/dd" />
    </vlayout>
</hlayout>
    <zscript><![CDATA[
        datebox.setLenient( false ); 
        datebox.setConstraint( "between 00010101 and 99991231" );
    ]]></zscript>
</zk>

Unfortunately the constraint lower value is automatically converted in "20010101"...

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2014-08-04 18:10:05 +0800

Seen: 65 times

Last updated: Aug 12 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More