Skip to main content

Form states and built-in validators

Learn Form states and built-in validators (Module 11 · Angular Forms, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What state is a form field in? Every control keeps FormControl states (CSS classes ng-valid , ng-dirty ... are added automatically): • pristine / dirty : dirty once the user changed the value. • untouched / touched : touched after the field loses focus (blur). • valid / invalid : all validators pass or at least one fails. Also pending (async validation running) and disabled . Good UX: show an error only when the field is invalid and touched , not as soon as the page opens.

More lessons in Module 11 · Angular Forms