Skip to main content
individualistic_Swirl5D2F
Known Participant
November 13, 2020
Answered

Required field activates after click on radio button?

  • November 13, 2020
  • 2 replies
  • 1553 views

Hello,
next question,

I've two radio buttons in one group
[   ] as of now or [  ] due date        also some seperate fields for day, month and year as  [M][M][D][D][Y][Y]

 

Is there a possibility, if you click on the "as of due date" button, that all text fields for the date are activated (writable + required)?

If the "writeable first" does not work, it would be good to know how to make it then a required field.

This topic has been closed for replies.
Correct answer try67

Add this to the code:

this.getField("Tag").value = "";
this.getField("Monat").value = "";
this.getField("Jahr").value = "";


Not sure why that's not working, but you can use this code to reset those fields to their default values:

this.resetForm(["Tag", "Monat", "Jahr"]);

2 replies

Nesa Nurani
Community Expert
Community Expert
November 16, 2020

You can use this code in one of the radio buttons to make fields writable and required
if you want them to be readonly and not required use same code in second radio button
just change true-false, false-true:
this.getField("Tag").required = true;
this.getField("Tag").readonly = false;
this.getField("Monat").required = true;
this.getField("Monat").readonly = false;
this.getField("Jahr").required = true;
this.getField("Jahr").readonly = false;

individualistic_Swirl5D2F
Known Participant
November 16, 2020

Thank you, this works almostly. But if I click on the 2nd radio button with this required code. And going back to the first radio button, the textfield are still required.

individualistic_Swirl5D2F
Known Participant
December 1, 2020

Add this to the code:

this.getField("Tag").value = "";
this.getField("Monat").value = "";
this.getField("Jahr").value = "";


It doesn't work. Text that has already been inserted will still remain and, as stated above in the code, the text field can no longer be edited.

try67
Community Expert
Community Expert
November 13, 2020

Yes, that's possible. What are the names of the fields and the export values of the radio-button group?

individualistic_Swirl5D2F
Known Participant
November 16, 2020

group name = gilt
radio button 1 = ab sofort

radio button 2 = ab fälligkeit

 

3x textfields called:

- Tag

- Monat

- Jahr