Required minimum 2 text fields out of 4 to be completed before submiting a form
Hi all. Need some help if possible. I have a submit button in my form running a Java Script to extract emails associated to checkboxes in that particular form. So this works like this:
var fields = ["Checkbox1", "Checkbox2", "Checkbox3", "Checkbox4"];
var addresses = [];
for (var i in fields) {
var v = this.getField(fields).valueAsString;
if (v!="Off") addresses.push(v);
}
- this.mailDoc({cTo: addresses.join(";"), cSubject: "Subject line goes here"});
And each checkbox has an email address as export value. This is all working fine. Now with all of this working I'm wondering if there is a chance to do the next:
- form has 4 required text fields. I want that user must fill up minimum 2 out of these 4 fields, before Submit button will work. Of course it is allowed to user to fill 3 or even all 4 required text fields and then to submit a form as well. Now I know that there is a validation script for required either text field 1 or 2 to be completed:
- this.getField("Name of other field").required = (event.value=="");
- event.target.required = true;
and set your fields as required, but then I have to run a Submit form on a submit button without possibility to extract emails associated to checkboxes. Hope all is clear, let me know if you need any other info.
Tnx to all in advance.
