Expand my Community achievements bar.

Set Date Range

Avatar

Level 2

I would like to use a function/routine that only allows users to pick dates between September and June in one instance and July and August for another. Any suggestions would be welcome.

5 Replies

Avatar

Former Community Member

Do you mean June-September and July-August?

For July-August, I called the date 'endDate' and added the following script to the exit event...

// form1.page1.subform1.endDate::exit - (JavaScript, client)

var dateStr = this.rawValue;

var mm = parseInt((dateStr.substring(5,7)),10);

if (!(mm == 7 || mm == 8)) {

  xfa.host.messageBox("Please enter a date between July and August.","Whoops",1);

}

Steve

Avatar

Level 2

My date range would be September 2009 to June 2010 for one case and July 2010 to August 2010 for the second case. Of course for the following calender school year it would then be September 2010 to June 2011 etc.

Avatar

Former Community Member

You are either going to have to issue a new form for each school year or enable the user to pick the school year.

In my example I assume you are going to issue a new form since I have hard-coded the years as follows:

// form1.page1.subform1.startDate::exit - (JavaScript, client)

var dateStr = this.rawValue;

var yyyy = parseInt((dateStr.substring(0,4)),10);

var mm = parseInt((dateStr.substring(5,7)),10);

if (yyyy == 2009) {

  if (mm != 9) {

    xfa.host.messageBox("The month for the school start date is incorrect.","Whoops",1);

  }

}

else {

  xfa.host.messageBox("The year for the school year start date is incorrect.","Whoops",1);

}

// form1.page1.subform1.endDate::exit - (JavaScript, client)
var dateStr = this.rawValue;
var yyyy = parseInt((dateStr.substring(0,4)),10);
var mm = parseInt((dateStr.substring(5,7)),10);
if (yyyy == 2010) {
  if (mm != 6) {
    xfa.host.messageBox("The month for the school end date is incorrect.","Whoops",1);
  }
}
else {
  xfa.host.messageBox("The year for the school year end date is incorrect.","Whoops",1);
}

Avatar

Level 2

Just a little more help here. I want to use the same form each year so I am not too concerned about the year. What I am concerned about is that only the specified month ranges (Sep to June) and (July to August) are available for each instance. I have tried the code and even when I select the correct month the error message is popping. I will do some more troubleshooting with the code and if needs be copy it in my next posting. Thanks so far to the pointers from Steve.