This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

validationMessage

Summary

Returns the error message that would be displayed if the user submits the form, or an empty string if no error message.

Property of dom/HTMLInputElementdom/HTMLInputElement

Syntax

Note: This property is read-only.

var validationMessage = inputElement.validationMessage;

Return Value

Returns an object of type StringString

The error message that would be displayed if the user submits the form, or an empty string if no error message.

Notes

Returns a string containing the standard or custom error message that would be displayed if the user submitted at this time. If no errors are present or the form would validate, an empty string is returned. The following example has a required field, and if the user types “fun” into it, a custom message is set. Try previewing without anything in the field, then enter values, including the word fun: Note For more code samples, see Form controls part 1 and Form controls part 2: validation on the Windows Internet Explorer sample site.

Related specifications

W3C HTML5
Working Draft
WHATWG HTML
Living Standard

See also

Related pages

Attributions