I am looking for a way to stop users from inputting multiple spaces. I have tried various solutions like the one provided in this link:
Unfortunately, none of them have worked for my specific case.
Although the code below works well generally, it doesn't solve my issue:
import { AbstractControl } from '@angular/forms';
export function removeSpaces(control: AbstractControl) {
if (control && control.value && !control.value.replace(/\s/g, '').length) {
control.setValue('');
}
return null;
}
I need a solution that will prevent users from entering repeated spaces, such as typing "John ________ John-TEST ________ TEst".
The underscores represent multiple spaces on the keyboard.
If you know of a directive or have a solution, please share it with me.