Expand my Community achievements bar.

SOLVED

Default year in Date field

Avatar

Level 3

Hi I am creating a Date of Birth field in a form and was wondering if there was a way to alter the deafult year. Most users will be at least 25 so it would make sense to have my date drop down show you 1987 (for example) when it drops downs so that users don't have a far back to navigate.  Is this possible?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

here is a generic script that might help you.... I used this JavaScript in 'docReady' event of the Year dropdown...

if (this.rawValue == null || this.rawValue == "") {

    var d = new Date();

    var setValue = d.getFullYear() -25;

    this.rawValue = setValue;

}

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

here is a generic script that might help you.... I used this JavaScript in 'docReady' event of the Year dropdown...

if (this.rawValue == null || this.rawValue == "") {

    var d = new Date();

    var setValue = d.getFullYear() -25;

    this.rawValue = setValue;

}

Avatar

Level 3

Thank you, that does just what I want. 

The only little change I would like to make (if possible) is that I would like the DATE field to display empty when the form is first opened.  Is that possible? or do you need the date displayed to make the drop down to understand to show a date 25 years ago?

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----