web api instance method
ElementInternals: setFormValue() method
The setFormValue() method of the ElementInternals interface sets the element’s submission value and state, communicating these to the user agent.
Syntax
setFormValue(value)
setFormValue(value, state)
Parameters
valuestateOptional
[!NOTE] In general,
stateis used to pass information specified by a user, thevalueis suitable for submission to a server, post sanitization. For example, if a custom element asked a user to submit a date, the user might enter “3/15/2019”. This would be thestate. The server expects a date format of2019-03-15, the date in this format would be passed as thevalue.
Return value
Undefined.
Exceptions
NotSupportedErrorDOMException- : Thrown if the element does not have its
formAssociatedproperty set totrue.
- : Thrown if the element does not have its
Examples
In the following example, a checkbox custom element sets on as the value to send to the server, and checked as the state.
this.internals_.setFormValue("on", "checked");
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.