Skip to main content

Dirty Check

A form is "dirty" if any of its field has changed since:

  • it was loaded
  • or it was last reset
  • or it was last submitted

When the form is dirty:

  • <inform-el/> has a dirty attribute: <inform-el dirty />.
  • <inform-el/> has a dirty property:
document.querySelector("inform-el").dirty; // true

The example below uses the dirty attribute and CSS to show a warning only when the form is dirty:

Try changing the first name: the warning appears. Try setting the first name back to "changeme": the warning disappears!