This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 28, 2013, 3:58 PM
12 Posts
topic has been resolvedResolved

Set Min/Max ( constraints) in djDateTextBox

  • Category: Dojo and Client Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: djDateTextBox djDateTimeConstraints xpage constraints
  • Replies: 2
 hi,

i am searching for a solution to set min and max date of a djDateTextBox (the date bevor and after shouldn't be clickable)

In the dijit documentation i found this option (subtopic Changing Constraints on the Fly)

http://dojotoolkit.org/reference-guide/1.8/dijit/form/DateTextBox.html

 i found a lot of pages 

  • http://stackoverflow.com/questions/15098399/xpages-datetextbox-setting-constraints 
  • http://stackoverflow.com/questions/8743757/dojo-dijit-form-datetextbox-constraints-not-working-datetextbox
 

but nothing worked for me .


thx for your help 
Mar 28, 2013, 5:20 PM
17 Posts
Re: Set Min/Max ( constraints) in djDateTextBox
Try something like
call a function in ssjs to set the constraint, like
<xp:dateTimeHelper dojoType="dijit.form.DateTextBox"
                                    id="dateTimeHelper">
   <xp:this.dojoAttributes>
            <xp:dojoAttribute name="constraints">
                 <xp:this.value><![CDATA[#{javascript:return minmaxDatum()}]]></xp:this.value>
            </xp:dojoAttribute>

    </xp:this.dojoAttributes>
</xp:dateTimeHelper>

the function for minmaxDatum returns a mindate (in my case the start of a year) and a maxdate (here today)
the function pad is called to return the month and day with 2 digits (required for the constraints to work) 

function minmaxDatum() {

     function pad(n){return n<10 ? '0'+n : n}

     var jaar = sessionScope.AppSettings.get("boekJaar");
    var jaari = parseInt(jaar,10);
    var date1 = @Today();
    var year = @Year(date1);
    var month = @Month(date1);
    var day = @Day(date1);
   
    var vandaag = new Date(@Today());   
    var min = "min:'" + jaari + "-01-01'";
    var max = "max:'" + year + "-" + pad(month) + "-" + pad(day) + "'";
    return "{" + min + "," + max + "}";
}  
Apr 2, 2013, 6:57 AM
12 Posts
Re: Set Min/Max ( constraints) in djDateTextBox
Thank you very much indeed !

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal