up.form
JavaScript namespace
Features to submit and validate forms without a full page load.
Set an [up-submit] attribute to let Unpoly handle a form, or call up.submit() from JavaScript. The up:form:submit event lets your code observe or prevent any submission.
To render a new form state while the user is still typing, mark fields with [up-validate]. This shows validation errors as the user moves through the form, and can update other fields that depend on the changed value. [up-switch] shows, hides or disables other elements depending on a field's value, without a server request. [up-autosubmit] submits the form whenever a field changes, and up.watch() runs your own callback instead.
Features
-
Automatically submits a form when a field changes.
-
[up-autosubmit] ATTR
Automatically submits a form when a field changes.
-
[up-disable-for] ATTR
Disables this element while an input field with
[up-switch]has one of the given values. -
[up-enable-for] ATTR
Enables this element while an input field with
[up-switch]has one of the given values. -
Marks this element as a from group, which (usually) contains a label, input and error message.
-
up.form.config CONFIG
Sets default options for form submission and validation.
-
Returns a list of form fields within the given element.
-
Returns the form group for the given element.
-
[up-form-group] ATTR
Marks this element as a form group, which (usually) contains a label, input and error message.
-
Returns whether the given element is a form field, such as
inputorselect. -
Returns whether the given form will be submitted through Unpoly instead of making a full page load.
-
up:form:submit EVENT
This event is emitted when a form is submitted through Unpoly.
-
Returns a list of submit buttons within the given element.
-
Parses the render options that would be used to submit the given form, but does not render.
-
up:form:switch EVENT
When an
[up-switch]field changes, this event is emitted on all dependent elements. -
up:form:validate EVENT
This event is emitted before a form is being validated.
-
[up-hide-for] ATTR
Hides this element while an input field with
[up-switch]has one of the given values. -
Watches form fields and runs a callback when a value changes.
-
Observes form fields and runs a callback when a value changes.
-
[up-show-for] ATTR
Only shows this element if an input field with
[up-switch]has one of the given values. -
Submits a form via JavaScript and updates a fragment with the server response.
-
[up-submit] ATTR
Submits this form via JavaScript and updates a fragment with the server response.
-
[up-switch] ATTR
Controls the state of another element when this field changes.
-
Renders a new form state from its current field values, to show validation errors or update dependent elements.
-
[up-validate] ATTR
Renders a new form state when a field changes, to show validation errors or update dependent elements.
-
Watches form fields and runs a callback when a value changes.
-
[up-watch] ATTR
Watches form fields and runs a callback when a value changes.