xfa.host.validationsEnabled won't affect the mandatory property of fields. It will only set whether validation scripts are executed or not.
As I described earlier, there are two ways of validating fields:
- Using the
mandatory property in script or setting the Type property on the Value tab in the Object palette to
User Entered - Recommended or
User Entered - Required. The only way to disable this kind of validation at runtime (in Acrobat) is to use the "this.mandatory = 'disabled';" statement.
- Using validation scripts (scripts which evaluate to a boolean expression -- true or false) set on each field's Validate event which you can disable with the help of xfa.host.validationsEnabled. The catch, though, with script validations, is that fields with null values don't get validated (all field's with no default value are initially null when the form is first open in Acrobat).
I tried your code snippet in a little form I created and didn't find any problems. I've attached the form. In it, you'll see that there's a drop down list and a date time field which are
User Entered - Required and which get set to optional with your code snippet on the email submit button's PreSubmit event. You'll also notice that there's a text field which is
User Entered - Optional but has a validation script in its Validate event which verifies that the field's value is "1" and that validations are enabled.
When you click on the button, the drop down list and date time field become optional and you're permitted to submit the form because the text field's value is null (validation script isn't executed). If you enter anything but a single "1" in the text field and try to submit again, you won't be allowed to because of the validation script error. You can then un-comment the following line at the top of the email submit button's PreSubmit script:
//xfa.host.validationsEnabled = false;
This should let you submit the form even if the value entered into the text field is something other than "1".
If this still doesn't help, I'd be curious to know what version of Acrobat you're using.
Stefan
Adobe Systems