Skip to main content
danielh43624232
Participating Frequently
January 22, 2025
Question

Formular "Wenn Feld aktiviert, dann wird ein andres Fled Pflichtfeld"

  • January 22, 2025
  • 1 reply
  • 800 views

Hallo, ich habe ein Problem,

 

ich habe ein Kontrollkästchen und ein Eingabefeld "Textfeld".

Ich möchte nun, wenn das Kontrollkästchen aktiviert wird, das nun das Textfeld daneben ein Pflichfeld wird.

wird es wieder daktiviert, dann nicht mehr.

Hat hier jemand eine Lösung?

 

Vielen Dank!

1 reply

PDF Automation Station
Community Expert
Community Expert
January 22, 2025

Enter the following mouse up action script in the check box:

if(event.target.value!="Off")

{this.getField("Text field").required=true}

else

{this.getField("Text field").required=false}

danielh43624232
Participating Frequently
January 22, 2025

Thank you very much, that worked really well.

Now I have another question, I have a lot of selection fields on one page. Can I say that only a maximum of 5 can be selected?

danielh43624232
Participating Frequently
January 23, 2025

You can run a script to count the check boxes that are already selected and if there are already 5, the 6th will not check.  However, you should add an alert so you don't drive users crazy trying to figure out why they can't select a 6th.  Assume 10 check boxes named "Check Box.0" through "Check Box.9".  Add the following mouse up action to each check box before the original scrip:

 

 

var count=0;
for(var i=0;i<10;i++)
{
if(this.getField("Check Box."+i).value!="Off")
{count++}
}

if(count>5)
{
app.alert("You have exceeded 5 check boxes.  Please uncheck one.",1);
event.target.value="Off";
}

 

 


I have now solved it by adding another action that resets the field.
I have one more question: can you limit it in the script so that you can definitely only tick 5 and only select a new field once you have deactivated a field? Currently, I can still tick another one after the warning message.