Class ValidityState
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The ValidityState interface represents the validity states that an element can be in, with respect to constraint validation. Together, they help explain why an element's value fails to validate, if it's not valid.
[Value("ValidityState")]
public class ValidityState
- Inheritance
-
ValidityState
- Inherited Members
Remarks
Constructors
ValidityState()
public ValidityState()
Properties
BadInput
The read-only badInput property of the ValidityState interface indicates if the user has provided input that the browser is unable to convert. For example, if you have a number input element whose content is a string.
[Value("badInput")]
public bool BadInput { get; }
Property Value
- bool
A boolean that is
trueif theValidityStateobject does not conform to the expected type.
Remarks
-ValidityState valid, customError properties.
-Guide: Constraint validation
-Tutorial: Form data validation
CustomError
The read-only customError property of the ValidityState interface returns true if an element doesn't meet the validation required in the custom validity set by the element's SetCustomValidity(string) method.
[Value("customError")]
public bool CustomError { get; }
Property Value
- bool
A boolean that is
trueif a custom error message has been set to a non-empty string.
Remarks
-ValidityState badInput, valid properties.
-Constraint validation
-Forms: Data form validation
PatternMismatch
The read-only patternMismatch property of the ValidityState interface indicates if the value of an input, after having been edited by the user, does not conform to the constraints set by the element's pattern attribute.
[Value("patternMismatch")]
public bool PatternMismatch { get; }
Property Value
- bool
A boolean that is
trueif theValidityStateobject does not conform to the constraints.
Remarks
The patternMismatch property will be true if and only if the following conditions are all true:
-Constraint validation
-Forms: Data form validation
-Regular Expressions
RangeOverflow
The read-only rangeOverflow property of the ValidityState interface indicates if the value of an input, after having been edited by the user, does not conform to the constraints set by the element's max attribute.
[Value("rangeOverflow")]
public bool RangeOverflow { get; }
Property Value
- bool
A boolean that is
trueif theValidityStatedoes not conform to the constraints.
Remarks
If the field is numeric in nature, including the input/date, input/month, input/week, input/time, input/datetime-local, input/number and input/range types and a max value is set, if the value doesn't conform to the constraints set by the max value, the rangeOverflow property will be true.
-RangeUnderflow
-Constraint validation
-Forms: Data form validation
-step attribute
-min attribute
RangeUnderflow
The read-only rangeUnderflow property of the ValidityState interface indicates if the value of an input, after having been edited by the user, does not conform to the constraints set by the element's min attribute.
[Value("rangeUnderflow")]
public bool RangeUnderflow { get; }
Property Value
- bool
A boolean that is
trueif theValidityStatedoes not conform to the constraints.
Remarks
If the field is numeric in nature, including the input/date, input/month, input/week, input/time, input/datetime-local, input/number and input/range types and a min value is set, if the value doesn't conform to the constraints set by the min value, the rangeUnderflow property will be true.
-RangeOverflow
-Constraint validation
-Forms: Data form validation
-step attribute
-max attribute
StepMismatch
The read-only stepMismatch property of the ValidityState interface indicates if the value of an input, after having been edited by the user, does not conform to the constraints set by the element's step attribute.
[Value("stepMismatch")]
public bool StepMismatch { get; }
Property Value
- bool
A boolean that is
trueif theValidityStatedoes not conform to the constraints.
Remarks
If the field is numeric in nature, including the input/date, input/month, input/week, input/time, input/datetime-local, input/number and input/range types and the step value is not any, if the value don't doesn't conform to the constraints set by the step and min values, then stepMismatch will be true. If the remainder of the form control's value less the min value, divided by the step value (which defaults to 1 if omitted) is not zero, there is a mismatch.
-Constraint validation
-Forms: Data form validation
-step attribute
TooLong
The read-only tooLong property of the ValidityState interface indicates if the value of an input or textarea, after having been edited by the user, exceeds the maximum code-unit length established by the element's maxlength attribute.
[Value("tooLong")]
public bool TooLong { get; }
Property Value
- bool
A boolean that is
trueif theValidityStatedoes not conform to the constraints.
Remarks
TooShort
The read-only tooShort property of the ValidityState interface indicates if the value of an input, button, select, output, fieldset or textarea, after having been edited by the user, is less than the minimum code-unit length established by the element's minlength attribute.
[Value("tooShort")]
public bool TooShort { get; }
Property Value
- bool
A boolean that is
trueif theValidityStatedoes not conform to the constraints.
Remarks
TypeMismatch
The read-only typeMismatch property of the ValidityState interface indicates if the value of an input, after having been edited by the user, does not conform to the constraints set by the element's type attribute.
[Value("typeMismatch")]
public bool TypeMismatch { get; }
Property Value
- bool
A boolean that is
trueif theValidityStatedoes not conform to the constraints.
Remarks
If the type attribute expects specific strings, such as the input/email and input/url types and the value doesn't conform to the constraints set by the type, the typeMismatch property will be true.
The input/email input type expects one or more valid email addresses, depending on whether the multiple attribute is present. A valid email address includes an email prefix and a domain, with or without a top level domain. If the value of the email input is not an empty string, a single valid email address, or one or more comma separated email address if the multiple attribute is present, there is a typeMismatch.
The input/url input type expects one or more valid URLs, depending on whether the multiple attribute is present. A valid URL includes a protocol, optionally with an IP address, or an optional subdomain, domain, and top level domain combination. If the value of the URL input is not an empty string, a single valid URL, or one or more comma separated URLS if the multiple attribute is present, there is a typeMismatch.
Input type | Value | Expected value |
| email address, with or without TLD | |
| protocol or full URL with protocol |
-ValidityState badInput, valid, customError properties.
-Constraint validation
-Forms: Data form validation
-Regular Expressions
Valid
The read-only valid property of the ValidityState interface indicates if the value of an input element meets all its validation constraints, and is therefore considered to be valid.
[Value("valid")]
public bool Valid { get; }
Property Value
- bool
A boolean that is
trueif theValidityStatedoes conform to all the constraints.
Remarks
If true, the element matches the :valid CSS pseudo-class; otherwise the :invalid CSS pseudo-class applies.
-ValidityState badInput, customError properties.
-Constraint validation
-Forms: Data form validation
ValueMissing
The read-only valueMissing property of the ValidityState interface indicates if a required control, such as an input, select, or textarea, has an empty value.
[Value("valueMissing")]
public bool ValueMissing { get; }
Property Value
- bool
A boolean that is
trueif theValidityStateis not set and therequiredattribute is.
Remarks
If the required attribute is set, and no option is selected or a <textarea> or user-editable <input> is empty, the valueMissing property will be true. The property is only true if the field is required and has no value; if the field is not required, or if the field is required and has a value, the value is false.
-ValidityState badInput, valid properties.
-Constraint validation
-Forms: Data form validation
-Regular Expressions