public interface ValidatableHTMLElement
An
HTMLElement that supports client-side validation using the Constraint Validation API.
This works together with ValidatableHtmlElement.
Shared implementation of the HTML Constraint Validation API's
checkValidity()/reportValidity() behavior, for JS host objects wrapping
an ValidatableHtmlElement. Centralizes 'invalid'
event dispatch and the interactive-vs-static distinction between the two
methods (reportValidity() additionally focuses the element on failure)
so this isn't duplicated per element type -- each implementing class
only needs to supply the underlying DOM element.
- Author:
- Ronald Brill
- See Also:
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic booleandoCheckValidity(HtmlElement elem) Statically validates the underlying element's constraints, firing a cancelable 'invalid' event on it if invalid.static booleandoReportValidity(HtmlElement elem) Interactively validates -- same static check and 'invalid' event asdoCheckValidity(HtmlElement), but additionally focuses the element if it's invalid.static StringReturns the validation message describing the currently failing constraint, or "" if valid or barred from validation.
-
Method Details
-
doCheckValidity
Statically validates the underlying element's constraints, firing a cancelable 'invalid' event on it if invalid. Does not move focus.- Parameters:
elem- theHtmlElementto work on- Returns:
trueif valid or barred from validation,falseotherwise
-
doReportValidity
Interactively validates -- same static check and 'invalid' event asdoCheckValidity(HtmlElement), but additionally focuses the element if it's invalid.- Parameters:
elem- theHtmlElementto work on- Returns:
trueif valid or barred from validation,falseotherwise
-
getValidationMessage
Returns the validation message describing the currently failing constraint, or "" if valid or barred from validation.- Parameters:
elem- theHtmlElementto work on- Returns:
- the validation message
-