Class HTMLButtonElement
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The HTMLButtonElement interface provides properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating {{HTMLElement("button")}} elements.
[Value("HTMLButtonElement")]
public class HTMLButtonElement : HTMLElement, PopoverInvokerElement
- Inheritance
-
HTMLButtonElement
- Implements
- Inherited Members
Remarks
-HTML element implementing this interface: button
Constructors
HTMLButtonElement()
public HTMLButtonElement()
Properties
Disabled
The HTMLButtonElement.disabled property indicates whether the control is disabled, meaning that it does not accept any clicks.
[Value("disabled")]
public bool Disabled { get; set; }
Property Value
- bool
A boolean value.
Remarks
Form
The form read-only property of the HTMLButtonElement interface returns an HTMLFormElement object that owns this {{htmlelement("button")}}, or null if this button is not owned by any form.
[Value("form")]
public HTMLFormElement? Form { get; }
Property Value
- HTMLFormElement
An HTMLFormElement or
null.
Remarks
-HTMLButtonElement
-HTMLFormElement
-button
-HTML form attribute
-HTML forms guide
FormAction
The formAction property of the HTMLButtonElement interface is the URL of the program that is executed on the server when the form that owns this control is submitted. It reflects the value of the <button>'s formaction attribute.
[Value("formAction")]
public string FormAction { get; set; }
Property Value
- string
A string. The URL for form submission.
Remarks
The value overrides the Action property of the HTMLFormElement interface if the form is submitted via the button. This property can be retrieved or set.
-FormEnctype
-FormMethod
-FormNoValidate
-FormTarget
-Sending form data
FormEnctype
The formEnctype property of the HTMLButtonElement interface is the {{Glossary("MIME_type", "MIME type")}} of the content sent to the server when the form is submitted. It reflects the value of the <button>'s formenctype attribute.
[Value("formEnctype")]
public string FormEnctype { get; set; }
Property Value
- string
A string.
Remarks
The value overrides the Enctype property of the HTMLFormElement interface if the form is submitted via the submit button. This property can be retrieved or set. If not set, the value is the empty string ("").
-FormAction
-FormMethod
-FormNoValidate
-FormTarget
-Enctype
-Sending form data
FormMethod
The formMethod property of the HTMLButtonElement interface is the {{Glossary("HTTP")}} method used to submit the {{HtmlElement("form")}} if the {{HTMLElement("button")}} element is the control that submits the form. It reflects the value of the <button>'s formmethod attribute.
[Value("formMethod")]
public string FormMethod { get; set; }
Property Value
- string
A string;
"post","get","dialog", or"".
Remarks
The value overrides the Method property of the HTMLFormElement interface if the form is submitted via the button. This property can be retrieved or set. If set with an empty or invalid value, the invalid default value is "get". If not set at all, the value is the empty string ("").
-FormAction
-FormEnctype
-FormNoValidate
-FormTarget
-Method
-Sending form data
FormNoValidate
The formNoValidate property of the HTMLButtonElement interface is a boolean value indicating if the {{htmlelement("form")}} will bypass constraint validation when submitted via the button. It reflects the <button> element's formnovalidate attribute.
[Value("formNoValidate")]
public bool FormNoValidate { get; set; }
Property Value
- bool
A boolean.
Remarks
Its value overrides the NoValidate property of the HTMLFormElement interface if the form is submitted via the button. This property can be retrieved or set.
-ReportValidity()
-CheckValidity()
-FormAction
-FormEnctype
-FormMethod
-FormTarget
-form
-NoValidate
-FormNoValidate
-Learn: Client-side form validation
-Guide: Constraint validation
FormTarget
The formTarget property of the HTMLButtonElement interface is the tab, window, or iframe where the response of the submitted {{HtmlElement("form")}} is to be displayed. It reflects the value of the {{HTMLElement("button")}} element's formtarget attribute.
[Value("formTarget")]
public string FormTarget { get; set; }
Property Value
- string
A string.
Remarks
The value overrides the Target property of the HTMLFormElement interface if the form is submitted via the button. This property can be retrieved or set. If not set, the value is the empty string ("").
-FormAction
-FormEnctype
-FormNoValidate
-FormMethod
-Target
-Sending form data
Labels
The HTMLButtonElement.labels read-only property returns a
NodeList of the {{HTMLElement("label")}} elements associated with the
button element.
[Value("labels")]
public NodeList Labels { get; }
Property Value
- NodeList
A NodeList containing the
<label>elements associated
with the<button>element.
Remarks
Name
The name property of the HTMLButtonElement interface indicates the name of the {{HTMLElement("button")}} element or the empty string if the element has no name. It reflects the element's name attribute.
[Value("name")]
public string Name { get; set; }
Property Value
- string
A string representing the element's name.
Remarks
Type
The type property of the HTMLButtonElement interface is a string that indicates the behavior type of the {{HTMLElement("button")}} element.
[Value("type")]
public string Type { get; set; }
Property Value
- string
A string representing the type.Its possible values are listed in the attribute's button types section.
Remarks
ValidationMessage
The validationMessage read-only property of the HTMLButtonElement interface returns a string representing a localized message that describes the validation constraints that the {{htmlelement("button")}} control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (the <button>'s type is button or reset), or it satisfies its constraints.
[Value("validationMessage")]
public string ValidationMessage { get; }
Property Value
- string
A string.
Remarks
If the <button> is a candidate for constraint validation (the type is set or defaults to submit and WillValidate is true) and the constraints are not met (there is a non-null CustomError), the value is the error message that would be shown to the user during element validation.
-button
-HTMLButtonElement
-WillValidate
-Validity
-CheckValidity()
-ReportValidity()
-SetCustomValidity(string)
-Learn: Client-side form validation
-Guide: Constraint validation
-CSS :valid and :invalid pseudo-classes
Validity
The validity read-only property of the HTMLButtonElement interface returns a ValidityState object that represents the validity states this element is in.
[Value("validity")]
public ValidityState Validity { get; }
Property Value
- ValidityState
A ValidityState object.
Remarks
Value
The value property of the HTMLButtonElement interface represents the value of the {{htmlelement("button")}} element as a string, or the empty string if no value is set. It reflects the element's value attribute.
[Value("value")]
public string Value { get; set; }
Property Value
Remarks
WillValidate
The willValidate read-only property of the HTMLButtonElement interface indicates whether the {{htmlelement("button")}} element is a candidate for constraint validation. It is false if any conditions bar it from constraint validation, including:
[Value("willValidate")]
public bool WillValidate { get; }
Property Value
- bool
A boolean value.
Remarks
Methods
CheckValidity()
The checkValidity() method of the HTMLButtonElement interface returns a boolean value which indicates if the element meets any constraint validation rules applied to it. If false, the method also fires an HTMLElementinvalid event on the element. Because there's no default browser behavior for checkValidity(), canceling this invalid event has no effect. It always returns true if the {{HTMLElement("button")}} element's HTMLButtonElementtype is "button" or "reset", because such buttons are never candidates for constraint validation.
[Value("checkValidity")]
public bool CheckValidity()
Returns
- bool
Returns
trueif the element's value has no validity problems; otherwise, returnsfalse.
Remarks
NOTE
An HTML button element of the
"submit"type with a non-null ValidationMessage is considered invalid, will match the CSS {{cssxref(":invalid")}} pseudo-class, and will causecheckValidity()to return false. Use the SetCustomValidity(string) method to set the ValidationMessage to the empty string to set the Validity state to be valid.
-ReportValidity()
-button
-form
-Learn: Client-side form validation
-Guide: Constraint validation
-CSS :valid and :invalid pseudo-classes
ReportValidity()
The reportValidity() method of the HTMLButtonElement interface performs the same validity checking steps as the CheckValidity() method. In addition, if the HTMLElementinvalid event is not canceled, the browser displays the problem to the user.
[Value("reportValidity")]
public bool ReportValidity()
Returns
- bool
Returns
trueif the element's value has no validity problems; otherwise, returnsfalse.
Remarks
-CheckValidity()
-button
-form
-Learn: Client-side form validation
-Guide: Constraint validation
-CSS :valid and :invalid pseudo-classes
SetCustomValidity(string)
The setCustomValidity() method of the HTMLButtonElement interface sets the custom validity message for the {{htmlelement("button")}} element. Use the empty string to indicate that the element does not have a custom validity error.
[Value("setCustomValidity")]
public GlobalObject.Undefined SetCustomValidity(string error)
Parameters
errorstring