Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

HTML Constraint Validation

HTML5 introduced a new validation concept called constraint validation.

Constraint validation in HTML is based on:

  • Constraint validation HTML input attributes
  • Constraint validation CSS pseudo-selectors
  • Constraint validation DOM properties and methods

Constraint Validation HTML Input Attributes

Attribute

Description

disabled

Indicates that the input element should be disabled.

max

Defines the maximum value for an input element.

min

Sets the minimum value for an input element.

pattern

Defines the value pattern for an input element.

required

Indicates that the input field is required.

type 

Defines the type of an input element.

Constraint Validation CSS Pseudo Selectors

Selector

Description

:disabled

Selects input elements that have the “disabled” attribute.

:invalid

Selects input elements that contain invalid values.

:optional

Selects input elements that do not have the “required” attribute.

:required

Selects input elements that have the “required” attribute.

:valid

Selects input elements that contain valid values.