Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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}
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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";
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Unfortunately, deactivation doesn't work the way I wanted. I still need a solution here. 😞
Can't you edit posts here?