Adobe acrobat forms javascript object specification User Manual

Page of 64
Acrobat Forms - JavaScript Object Specification
35
app.alert("Invalid value for field " + event.target.name);
event.rc = false;
}
For a calculate event, JavaScript should set this property. This is the value that the field should
take upon completion of the event. For example, the following JavaScript sets the calculated
value of the field to the value of the SubTotal field plus tax.
var f = this.getField("SubTotal");
event.value = f.value * 1.0725;
For a format event, JavaScript should set this property. This is the value used when generating
the appearance for the field. By default, it contains the value that the user has committed. For
example, the following JavaScript formats the field as a currency type of field.
event.value = util.printf("$%.2f", event.value);
willCommit
Type: Boolean
Event: Keystroke
Access: R
Use this property to verify the current keystroke event before the data is committed. This is
useful to check the target form field values and for example verify if character data instead of
numeric data was entered. JavaScript sets this property to true after the last keystroke event
and before the field is validated.
Example:
var value = event.value
if (event.willCommit)
// Final value checking.
else
// Keystroke level checking.
For more examples of using willCommit, refer to the Acrobat Forms JavaScript application
(Aform.js) in your Acrobat plug-ins directory.