Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 1.05 KB

what_are_the_available_constraint_validation_dom_properties.md

File metadata and controls

22 lines (15 loc) · 1.05 KB

What are the available constraint validation DOM properties?

The following properties are available for constraint validation in the DOM:

  • validity: An object that contains various validity states of the input element.
  • valueMissing: Returns true if the input is required but empty.
  • typeMismatch: Returns true if the input value doesn't match the expected type.
  • tooLong: Returns true if the value is too long for the field.
  • rangeUnderflow: Returns true if the value is less than the minimum value.

Example:

const input = document.querySelector('input');
console.log(input.validity.rangeUnderflow); // true or false

Tags: intermediate, JavaScript, DOM, validation

URL: https://www.tiktok.com/@jsmentoring/photo/7464745553981672736