Setting a field as required at run time
example demonstrates how to make a field required at run time.
In this example, when the Set as Required button is clicked,
if the form filler attempts to submit a form without typing some
text in TextField1, an error message appears.
To see this scripting example and others, visit the
Scripting for the Set as Required button
following script is for the Set as Required button:
TextField1.validate.nullTest = "error";
can also use one of these two scripts:
TextField1.mandatory = "error"
TextField1.mandatoryMessage = "this field is mandatory!"