Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Date field populates depending on when form opens

Avatar

Level 3

Hi - I have a form to be submitted that includes a list of subjects for a particular meeting that happens each Monday. Can a date field populate with the date of that Monday when the form opens in the preceeding week? And then happen each week after that?

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 5

Are you generating a new form each week?

If so, this will get the date for next Monday - you can play with the format:

var d = new Date();

d.setDate(d.getDate() + (1 + 7 - d.getDay()) % 7);

this.rawValue = d;

If you are using the same form for multiple weeks, then you would need to test to see if the current field value was less that the value generated by the script and replace in the field if needed.

Good Luck,

View solution in original post

1 Reply

Avatar

Correct answer by
Level 5

Are you generating a new form each week?

If so, this will get the date for next Monday - you can play with the format:

var d = new Date();

d.setDate(d.getDate() + (1 + 7 - d.getDay()) % 7);

this.rawValue = d;

If you are using the same form for multiple weeks, then you would need to test to see if the current field value was less that the value generated by the script and replace in the field if needed.

Good Luck,