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.
Example
Section titled “Example”<form method="post" action="/address"> <gatepost-postcode-field name="postcode" required></gatepost-postcode-field> <button>Save</button></form>Extends
Section titled “Extends”HTMLElement
Properties
Section titled “Properties”
readonlyform:HTMLFormElement|null
The form that holds the field, or null.
validationMessage
Section titled “validationMessage”
readonlyvalidationMessage:string
The message that the browser shows for an invalid field, or an empty text.
validity
Section titled “validity”
readonlyvalidity:ValidityState
The validity of the field, as for a native input.
willValidate
Section titled “willValidate”
readonlywillValidate:boolean
True when a form checks the field before it submits.
Accessors
Section titled “Accessors”messages
Section titled “messages”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”Set Signature
Section titled “Set Signature”set messages(
messages):void
Parameters
Section titled “Parameters”messages
Section titled “messages”Partial<Messages>
Returns
Section titled “Returns”void
Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”string
Set Signature
Section titled “Set Signature”set value(
text):void
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Methods
Section titled “Methods”attributeChangedCallback()
Section titled “attributeChangedCallback()”attributeChangedCallback(
name):void
Applies a changed attribute. The browser calls it.
Parameters
Section titled “Parameters”string
The name of the attribute.
Returns
Section titled “Returns”void
checkValidity()
Section titled “checkValidity()”checkValidity():
boolean
Checks the field as a form does before it submits.
Returns
Section titled “Returns”boolean
True when the field is valid. Otherwise false, after an invalid event.
connectedCallback()
Section titled “connectedCallback()”connectedCallback():
void
Reads the settings and checks the text. The browser calls it on insertion.
Returns
Section titled “Returns”void
disconnectedCallback()
Section titled “disconnectedCallback()”disconnectedCallback():
void
Cancels any request and forgets its outcome. The browser calls it on removal.
Returns
Section titled “Returns”void
formDisabledCallback()
Section titled “formDisabledCallback()”formDisabledCallback(
disabled):void
Turns the controls off or on with the form. The browser calls it.
Parameters
Section titled “Parameters”disabled
Section titled “disabled”boolean
True when the field or its fieldset is disabled.
Returns
Section titled “Returns”void
formResetCallback()
Section titled “formResetCallback()”formResetCallback():
void
Puts the text of the value attribute back. The browser calls it when the form resets.
Returns
Section titled “Returns”void
formStateRestoreCallback()
Section titled “formStateRestoreCallback()”formStateRestoreCallback(
state):void
Puts back the text that the user had typed, for example after the back button. The browser calls it.
Parameters
Section titled “Parameters”unknown
The text that the field saved with its form value.
Returns
Section titled “Returns”void
reportValidity()
Section titled “reportValidity()”reportValidity():
boolean
Checks the field, and shows its error to the user when it is invalid.
Returns
Section titled “Returns”boolean
True when the field is valid.
Unofficial. Not made or endorsed by NIPOST.