0

Compare dates client side

asked 2015-10-08 13:51:23 +0800

greendragon gravatar image greendragon
25 4

Hello! I've a form with two dates, and I wanto to insert a constrait on them: the second date must be grater than the first date. I want to do this client side but I've no idea how get the values inserted in dateboxes. This is my code:

...
<datebox id="fromDate" format="short" constraint="no past" value="@bind(myVM.fromDate)"></datebox>
<datebox format="short" constraint="no past" value="@bind(myVM.toDate)" 
w:onChange="changeDate();"></datebox>
...
<script type="text/javascript">
    function changeDate() {
        var x = jq('$toDate');
        ...???...
    }
</script>

How can I get the date value from x? Very thanks...

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted
0

answered 2015-10-08 15:04:48 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

either way is the same.

jq('$db').zk.$().getValue()
// or
zk('$db').$().getValue();
link publish delete flag offensive edit
0

answered 2015-10-08 15:12:06 +0800

Darksu gravatar image Darksu
1991 1 4

Hello greendragon,

Please use the following code in order to update the second datebox with the value from the first one:

<zk xmlns:w="client">
    <datebox 
        id="dbx"  
        w:onChange="
        var origin = zk.Widget.$('$dbx');

        var t = zk.Widget.$('$dbx2');
        t.$n('real').value=( origin.$n('real').value );
        t.updateChange_();" />
    <datebox id="dbx2"  />    
</zk>

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-10-09 12:53:06 +0800

greendragon gravatar image greendragon
25 4

Thanks! Both the answers are working!

link publish delete flag offensive edit
0

answered 2015-10-14 10:53:43 +0800

greendragon gravatar image greendragon
25 4

updated 2015-10-14 10:58:32 +0800

Hello! I solved the problem with the datebox:

var toDate = new Date(jq('$toDate').zk.$().getValue());

Thanks

link publish delete flag offensive edit
0

answered 2015-10-14 11:03:52 +0800

Darksu gravatar image Darksu
1991 1 4

Hello greendragon,

Here is the respective with timebox:

<zk xmlns:w="client">
    <timebox 
        id="dbx"  
        w:onClick="
        var origin = zk.Widget.$('$dbx');

        var t = zk.Widget.$('$dbx2');
        t.$n('real').value=( origin.$n('real').value );
        t.updateChange_();" />
    <timebox id="dbx2"  />    
</zk>

You had to change the component, and use the onClick event in order to make it work.

Best Regards,

Darksu

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
1 follower

RSS

Stats

Asked: 2015-10-08 13:51:23 +0800

Seen: 57 times

Last updated: Oct 14 '15

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