Eusthace Eusthace - 7 months ago 257
TypeScript Question

How to validate white spaces/empty spaces? [Angular 2]

I would like to avoid white spaces/empty spaces in my angular 2 form?
Is it possible?
How can this be done?


Maybe this article can help you

In this approach, you have to use FormControl then watch for value changes and then apply your mask to the value. An example should be:

form: FormGroup;

            .map((value) => {
                // Here you can manipulate your value
                value.firstName = value.firstName.trim();
                return value;
            .filter((value) => this.form.valid)
            .subscribe((value) => {
               console.log("Model Driven Form valid value: vm = ",JSON.stringify(value));