Skip to content

pantoken-root / formats/interactions/src / initFormField

Function: initFormField() ​

initFormField(host, control, error): FormFieldHandle

Associate an authored error after blur, native invalid events, or explicit validation. Untouched fields stay quiet; edited fields revalidate after the first validation attempt. Preserves hint references and uses native constraints, including setCustomValidity(). The host must contain the control and a separate, named error element with message text. Clean up and reinitialise after moving controls between forms or changing error IDs.

Parameters ​

host ​

HTMLElement

control ​

FormFieldControl

error ​

HTMLElement

Returns ​

FormFieldHandle