Skip to content

Securing Forms

Forms must validate user input to prevent attacks.

HTML Example

<input type="email" required pattern="^[^@]+@[^@]+\.[^@]+$" />

TypeScript Example

import { FormControl, Validators } from "@angular/forms";
email = new FormControl("", [Validators.required, Validators.email]);

Explanation

Validation prevents invalid or malicious input.