0

Datebox constraints

asked 2018-11-30 07:00:23 +0800

bztom35 gravatar image bztom35
1 1

updated 2018-11-30 07:54:51 +0800

I am trying to limit the date input to allow only from January to June.

<label value="Course Date:" sclass="labelstyle"/> <datebox id="sce_course_actual_date" format="MM/yyyy" width="200px" constraint="no empty" hflex="1" style="font-size:12pt; color: #00008B;" onfocus="self.select()"/>

solutions:

usage: <datebox id="mydate" format="MM/yyyy" sclass="datebox-month-only"/>

<zk> <script>Cwgt = {}; zk.override(zul.db.CalendarPop.prototype, _Cwgt, { // switch the view after redraw or open as needed redraw: function (out) { _Cwgt.redraw.apply(this, arguments); //call the original method this.customChangeView (); }, open: function (silent) { Cwgt.open.apply(this, arguments); //call the original method this.customChangeView (); }, customChangeView: function () { // cannot show month/day if (jq(this.parent.$n()).hasClass('datebox-year-only')) { var view = this.view; // switch to year view as needed if (view == 'month' || view == 'day') this.setView("year"); } else if (jq(this.parent.$n()).hasClass('datebox-month-only')) { // cannot show day view // switch to month view as needed if (this.view == 'day') this.setView("month"); } }, // customize the chooseDate function _chooseDate: function (target, val) { var view = this.view; if (jq(this.parent.$n()).hasClass('datebox-month-only') || jq(this.parent.$n()).hasClass('datebox-year-only')) { // do customize chooseDate if the parent (datebox) // has specific class var date = this.getTime(), year = (view == 'decade' || view == 'year')? val : date.getFullYear(), month = view == 'month'? val : 0, date = 1; // set date value this.setTime(year, month, 1); if (view == 'decade') { // switch to year view if at decade view this.setView("year"); } else if (jq(this.parent.$n()).hasClass('datebox-month-only') && view == 'year') { // switch to month view if at year view and the month view is allowed this.setView("month"); } else if (jq(this.parent.$n()).hasClass('datebox-month-only') && view == 'month' || jq(this.parent.$n()).hasClass('datebox-year-only') && view == 'year') { // close calendar and update value if already at the smallest allowed view this.close(); this.parent.setValue(this.getTime()); this.parent.fireOnChange(); } } else { _Cwgt.chooseDate.apply(this, arguments); //call the original method } } }); }); ]]></script> </zk>

delete flag offensive retag edit
Be the first one to answer this question!
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: 2018-11-30 07:00:23 +0800

Seen: 3 times

Last updated: Nov 30

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