InterviewHubPRO
Section Overview
Q280

Question 280 of 521

Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

54%
JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

What are the available constraint validation DOM properties

Below are the list of some of the constraint validation DOM properties available,

  1. validity: It provides a list of boolean properties related to the validity of an input element.
  2. validationMessage: It displays the message when the validity is false.
  3. willValidate: It indicates if an input element will be validated or not.

Practical Code Example

javascript
// HTML5 Constraint Validation DOM Properties on form inputs:
const input = document.getElementById('userEmail');

console.log(input.validity);         // ValidityState object
console.log(input.validationMessage);// Browser error message string
console.log(input.willValidate);     // Boolean whether element participates in validation