Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

Inter dependency between the fields of the form

Avatar

Level 8

Hello

I put a couple of free text fields and immediately next to it (free text field) i have placed a check box, fine. 

I have a requirement like below with 3 scenarios,

1) Once the user STARTED filling the data into that free text field, immediately the next check box must either hide or greyed out(readOnly).

2) If user did not touched that free text field at all, then user is allowed to check the check box, meanig its visible/editable, its normal anywyas.

3) Say, user started entering the data in free text field, immedtiately the check box got hidden/greyed out......fine...........but, in next second user has changed the mind and wiped off/erased the free text field's filled data and made it into blank back again....in this case, the check box should become visible/editable state (from hideen/greyed out state).

Preferably, hidden/visible makes more fancy

Pls. let me know the JavaScript to achieve my requirement and i guess, i need to write that suggetsed JS in CHANGE event, am i correct?

Actually, i have some drop-down fields also there instaed of free text fields on the form, pls. also provide me the JavaScript for these drop-down type of fields, if code is change from the free text fields.

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

(1) Yes, it will. The dropdown may need to be set to Allow Custom entry, so that the user can clear it.

(2) Yes, that is correct. The presence of the checkfield is dependant on the length of the user's data. No data - checkbox visble; Data - checkbox hidden.

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi,

Correct, the change event in the textfield would be a good choice:

if (xfa.event.newText.length > 0) {

     checkbox.presence = "hidden";

}

else {

     checkbox.presence = "visible";

}

Hope that helps,

Niall

Avatar

Level 8

Thank you.

Pls. let me know (as our system is down until next couple of hours, i can not test on my own, hence mean while i would like clarify the below points as well proir to our system is up, Thank you),

1) The same code/logic gonna work for drop-down fields aswell?

2) Does your code meet the below requirement as well?

Say, user started entering the data in free text field, immedtiately the check box got hidden/greyed out......fine...........but, in next second user has changed the mind and wiped off/erased the free text field's filled data and made it into blank back again....in this case, the check box should become visible/editable state (from hideen/greyed out state).

Thank you

Avatar

Correct answer by
Level 10

Hi,

(1) Yes, it will. The dropdown may need to be set to Allow Custom entry, so that the user can clear it.

(2) Yes, that is correct. The presence of the checkfield is dependant on the length of the user's data. No data - checkbox visble; Data - checkbox hidden.

Niall