ExecuteFormFieldScriptEvent

Forms, JavaScript safety

Description

Executes a field /K, /F, /V or /C action in the bounded local form-script runtime and returns the resulting event state

Syntax

Function TPDFlib.ExecuteFormFieldScriptEvent(Index: Integer; Action: TPDFlibFormScriptAction; Const InputEvent: TPDFlibFormScriptEvent; Out OutputEvent: TPDFlibFormScriptEvent): Integer;

Parameters

IndexThe one-based target field index
ActionThe field event to execute
InputEventThe initial value, change, source field, selection, key state and commit state
OutputEventThe final event state, including writable value, change, rc, selStart and selEnd properties

Return values

Returns 1 when execution succeeds and event.rc remains true, or 0 when the action is absent, rejects the event, is unsupported, is invalid or exceeds a resource limit

Remarks

The controlled object surface exposes standard field-event properties, read-only event.target and event.source field properties, this.numFields, this.getField(...) and this.getNthFieldName(...)

Field objects expose name, type, value, valueAsString, readonly, required and charLimit without allowing object mutation

The AFNumber_Keystroke, AFPercent_Keystroke, AFDate_KeystrokeEx, AFTime_Keystroke, AFSpecial_Keystroke and AFSpecial_KeystrokeEx helpers check the value the keystroke would produce while typing, and the complete value when WillCommit is true or during validation. Dates carry no time zone

Push buttons, check boxes and radio buttons reject /K, /F, /V and /C execution, and only a successful calculation writes the final value to the stored field

Helpers include AFMergeChange(event), util.printd and util.scand with the Acrobat date field codes, numeric new Date(...) values with getFullYear, getMonth, getDate, getDay, getHours, getMinutes, getSeconds and getTime, util.printf with the %d, %f, %s and %x conversions and the ,0 to ,4 separator styles, Math.pow and Math.sqrt, a global getField(...), and the string and number members length, toFixed, toString, toUpperCase, toLowerCase, trim, indexOf, charAt, substring and substr

The runtime has no file, network, process, UI, dynamic-code or unrestricted document-object capability. Host actions such as app.alert are never performed; SetFormScriptHostActionMode chooses whether they make the script unsupported or are reported to the application

See also

TPDFlibFormScriptEvent, SetFormScriptLimits, GetFormScriptDiagnostics, ExecuteFormFieldScript