Skip to content

PostcodeFieldElement

The postcode field, <gatepost-postcode-field>. A plain HTML form submits its form value: the canonical form of the postcode. It checks the format offline. With a publishable key in api-key, it also asks the gateway about each whole postcode.

<form method="post" action="/address">
<gatepost-postcode-field name="postcode" required></gatepost-postcode-field>
<button>Save</button>
</form>
  • HTMLElement

readonly form: HTMLFormElement | null

The form that holds the field, or null.


readonly validationMessage: string

The message that the browser shows for an invalid field, or an empty text.


readonly validity: ValidityState

The validity of the field, as for a native input.


readonly willValidate: boolean

True when a form checks the field before it submits.

get messages(): Messages

The messages that the field shows, from the English catalogue of the spec. A new object replaces messages by key, and a key that it leaves out keeps its English text.

Messages

set messages(messages): void

Partial<Messages>

void


get value(): string

The form value: the canonical form, the digits of a legacy postcode, or the trimmed text. A new value goes into the input as typed text, and raises no gatepost-change.

string

set value(text): void

string

void

attributeChangedCallback(name): void

Applies a changed attribute. The browser calls it.

string

The name of the attribute.

void


checkValidity(): boolean

Checks the field as a form does before it submits.

boolean

True when the field is valid. Otherwise false, after an invalid event.


connectedCallback(): void

Reads the settings and checks the text. The browser calls it on insertion.

void


disconnectedCallback(): void

Cancels any request and forgets its outcome. The browser calls it on removal.

void


formDisabledCallback(disabled): void

Turns the controls off or on with the form. The browser calls it.

boolean

True when the field or its fieldset is disabled.

void


formResetCallback(): void

Puts the text of the value attribute back. The browser calls it when the form resets.

void


formStateRestoreCallback(state): void

Puts back the text that the user had typed, for example after the back button. The browser calls it.

unknown

The text that the field saved with its form value.

void


reportValidity(): boolean

Checks the field, and shows its error to the user when it is invalid.

boolean

True when the field is valid.

Unofficial. Not made or endorsed by NIPOST.