0

datebox: let the latter datebox time be after the former datebox one

asked 2010-04-08 14:38:57 +0800

yuanbohan gravatar image yuanbohan
258 2 7

Hi,
I want to let the "to" date be after the "from" date, and I have two databox as following, so can anyone tell me how to constrain the "to" date be after the "from" date?

<vbox align="end">
<hbox>
<label value="From: " />
<datebox id="from" format="yyyy-MM-dd HH:mm:ss" width="120px" readonly="true" constraint="between 20100401 and 20101231" />
</hbox>

<hbox>
<label value="To: " />
<datebox id="to" format="yyyy-MM-dd HH:mm:ss" width="120px" readonly="true" constraint="between 20100401 and 20101231" />
</hbox>
</vbox>

thanks a lot. ^_^

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-04-12 20:16:17 +0800

iantsai gravatar image iantsai
2755 1

Implement your own Constraint to "to" Datebox, and this Constraint implementation requires "From" Datebox as input.

link publish delete flag offensive edit

answered 2010-04-14 13:44:23 +0800

yuanbohan gravatar image yuanbohan
258 2 7

hi iantsai, can you give me a example like this? thanks a lot for your time.

link publish delete flag offensive edit

answered 2010-04-14 21:20:36 +0800

jinowx5 gravatar image jinowx5
9

Hi yuanbohan

the following example works fine for me.

<zscript><![CDATA[
  import java.text.SimpleDateFormat;

	void fromChanged(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");  
		to.setConstraint("between " + sdf.format(from.getValue()) + " and 20101231" );
	}
]]>
</zscript>

<vbox align="end">
<label value="From: " />
<datebox id="from" format="yyyy-MM-dd HH:mm:ss" width="120px" readonly="true" constraint="between 20100401 and 20101231" onChange="fromChanged()/>
</hbox>

<hbox>
<label value="To: " />
datebox id="to" format="yyyy-MM-dd HH:mm:ss" width="120px" readonly="true" constraint="between 20100401 and 20101231" />
</hbox>
</vbox>

please try it.

Masuji

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2010-04-08 14:38:57 +0800

Seen: 447 times

Last updated: Apr 14 '10

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