Search.../

validity

Gets a ValidityState object that contains detailed information about the validity states of the element.

Type:

ValidityStateRead Only
NAME
TYPE
DESCRIPTION
customError
boolean

true if the element's custom validity message has been set to a non-empty string.

valid
boolean

true if the element meets all constraint validations.

valueMissing
boolean

true if the element's required property is true, but it does not contain a value.

typeMismatch
boolean

true if the text input element's value does not match its type when the type is email or url.

patternMismatch
boolean

true if the element's value does not match its pattern validation.

tooLong
boolean

true if the length of the element's value exceeds its maxLength property.

tooShort
boolean

true if the length of the element's value is smaller than its minlength property.

rangeUnderflow
boolean

true if the element's value is less than its min property.

rangeOverflow
boolean

true if the element's value is more than its max property.

fileNotUploaded
boolean

true if the element is an upload button that is required and a file has been selected but not uploaded.

stepMismatch
boolean

true if a text input element's numeric value is defined as a whole number but a decimal number is entered.

badInput
boolean

true if the element's value cannot be converted to a value.

invalidTime
boolean

true if the element's time value is not a valid time.

invalidDate
boolean

true if the element's date value is not a valid date.

Mixed in from:$w.FormElement

Related Content:

Was this helpful?

Log ValidityState info

Copy Code
1let validityObj = $w("#myElement").validity;
2
3let customError = validityObj.customError; // true
4let valid = validityObj.valid; // false
5let valueMissing = validityObj.valueMissing; // false
6let typeMismatch = validityObj.typeMismatch; // false
7let patternMismatch = validityObj.patternMismatch; // false
8let tooLong = validityObj.tooLong; // false
9let tooShort = validityObj.tooShort; // false
10let rangeUnderflow = validityObj.rangeUnderflow; // false
11let rangeOverflow = validityObj.rangeOverflow; // false
12let fileNotUploaded = validityObj.fileNotUploaded; // false
13let stepMismatch = validityObj.stepMismatch; // false
14let badInput = validityObj.badInput; // false
15let invalidTime = validityObj.invalidTime; // false
16let invalidDate = validityObj.invalidDate; // false