I am currently working on an Angular project using Ant Design ng Zorro. I've encountered an issue with validation when trying to restrict special characters in an input field. Despite setting up the validation rules, it seems that the key press event is not triggering the validation. Does anyone have a solution for this?
html
<nz-form-item >
<nz-form-control nzErrorTip="Company name is required!" >
<input
nz-input
placeholder="Type here"
formControlName="companyName"
nzSize="small"
/>
</nz-form-control>
</nz-form-item>
.ts
this.validateForm = this.fb.group(
companyName: [null, [Validators.required, Validators.pattern('^[a-zA-Z \-\']')]],
)