Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Jan 22, 2025 Jan 22, 2025

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!

TOPICS
PDF forms
815
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2025 Jan 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}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2025 Jan 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2025 Jan 22, 2025

No, but you can display an error message if more than 5 are selected, and prevent the file from being submitted while that is still the case. Both things require a script, of course.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2025 Jan 22, 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";
}

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2025 Jan 22, 2025

Thank you very much, I'll try that.

You've helped me a lot. If it doesn't work out, I'll be happy to get in touch again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2025 Jan 22, 2025

So I've integrated it now. Everything's working fine so far, if I activate more than 5 the message appears. But I can't deactivate any of the fields anymore, what am I missing in the script?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2025 Jan 23, 2025
LATEST

It works for me.  I always test before I post a solution to something I've never done before.  You ask "what am I missing in the script" without posting the form or the script.  Please post the form and I'll take a look.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2025 Jan 22, 2025

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2025 Jan 22, 2025

Unfortunately, deactivation doesn't work the way I wanted. I still need a solution here. 😞

 

Can't you edit posts here?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines