files/en-us/web/api/elementinternals/setformvalue/index.md
{{APIRef("Web Components")}}
The setFormValue() method of the {{domxref("ElementInternals")}} interface sets the element's submission value and state, communicating these to the user agent.
setFormValue(value)
setFormValue(value, state)
value
state {{optional_inline}}
[!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.
Undefined.
NotSupportedError {{domxref("DOMException")}}
formAssociated property set to true.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}}
{{Compat}}