Hello, In your code, the event object in the removeSpecialCharactersFromCity function is not the same as the one in the input element's event handlers. In the input element, you're using event.target.value to access the input's value, but in the autocomplete, event.target.value doesn't work because the event target is not the input element.
To fix this issue, you can modify your code as follows: https://www.myaccountaccess.one/
Pass the value directly to the removeSpecialCharactersFromCity function in the autocomplete's event handlers, instead of passing the entire event object. <mat-autocomplete autoActiveFirstOption #auto="matAutocomplete" (keydown)="removeSpecialCharactersFromCity($event.target.value)" (keyup)="removeSpecialCharactersFromCity($event.target.value)"> <mat-option ngFor="let option of cityFilteredOptions" [value]="option" (keydown)="removeSpecialCharactersFromCity($event.target.value)" (keyup)="removeSpecialCharactersFromCity($event.target.value)"> {{option}} Modify the removeSpecialCharactersFromCity function to accept the value as a parameter and perform the replace operation. removeSpecialCharactersFromCity(value: string) { this.adres.city = value.replace(/[&/#,+()$~%.]'":?<>{}@^&=;'"_![]/g, ''); } With these changes, the removeSpecialCharactersFromCity function will correctly replace the special characters in the city value when triggered by the autocomplete events.