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

Hidden field revealed when date / time field is changed

Avatar

Former Community Member

Hi,

How can I code my form so that when a user selects a date in the date / time field  it will then reveal a hidden text field, I am assuming this would be a "change" in javascript rather than on "exit".

Would appreciate any advice.

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can use presence property to hide/ display the fields.

FieldName.presence = "visible"; // Display the field.

FieldName.presence = "hidden"; // Hides the field.

You can decide on the event you want to place the code in based on your requirements. Exit event will be executed when the user leaves the field. Change event will be executed when the value changes in the field.

Thanks

Srini

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

You can use presence property to hide/ display the fields.

FieldName.presence = "visible"; // Display the field.

FieldName.presence = "hidden"; // Hides the field.

You can decide on the event you want to place the code in based on your requirements. Exit event will be executed when the user leaves the field. Change event will be executed when the value changes in the field.

Thanks

Srini

Avatar

Level 7

To specifiy when to run the presence code you can use the Date2Num function. This will translate a date into a number and then you can say that when the Date2Num result is equal to the date you want then the presence will change.