Copy link to clipboard
Copied
Hi
I have created a form with a number of fields that are required. In order for the person completing the form to check they have completed everything they have to I created a validate button with the below coding so a message pops up if they haven't completed all the fields.
if (
this.getField("Partnership status").value=="Off"||
this.getField("Question one").value=="Off"||
this.getField("Question two").value=="Off"||
this.getField("Question three").value=="Off"||
this.getField("Question four").value=="Off"||
this.getField("Question five").value=="Off"||
this.getField("Question six").value=="Off"||
this.getField("Declaration confirmation").value=="Off"
)
{app.alert("Please complete all required fields which are highlighted in red.")}
I have been asked however to make an additional field required "Date of event" depending on the answer given to "Partnership status" which is a group of radio buttons. To do this I've added to each radio button the following code with true or false depending on the action.
this.getField("Date of event").required = true;
I'm not sure though how to then add this in to the code for my validation button so that it can tell if this field is required or not and therefore needs completing or not. Thank you for any help with this.
Not sure if I understand it right , but you can implement into code to check if field is empty and required.
(this.getField("Date of event").value == "" && this.getField("Date of event").required == true);
Copy link to clipboard
Copied
Not sure if I understand it right , but you can implement into code to check if field is empty and required.
(this.getField("Date of event").value == "" && this.getField("Date of event").required == true);
Copy link to clipboard
Copied
Thanks, I've tried this but unfortunately the warning message isn't coming up for the validate button when the field has been made required but has been left blank.
Copy link to clipboard
Copied
Can you share your file?
Copy link to clipboard
Copied
Hi
Yes, it will be a public form so I've attached a copy. The validation has also stopped working now except for the Full name, Date of birth, and telephone number fields so if there is a better way to do the script for this to incorporate the Date of event field being required/or not, and completed or not, I'm happy to change it. Thanks for your help.
Copy link to clipboard
Copied
My code will work but you have error in your script, change field name "Daytime telephone number" to
"Daytime phone number".
Copy link to clipboard
Copied
That has all worked perfectly, thank you.