1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 06:43:35 +00:00
Files
browser/libs/angular/src/directives/input-strip-spaces.directive.ts
Conner Turnbull 36030c3763 [PM-9113] Trim Whitespace from email in sponsorship form (#9781)
* Removed whitespace from email form when setting up families sponsorship

* Moved sponsorship components to billing folder

* Updated to use existing input stripping directive

* Updated appInputStripSpaces to update both the element and the control value

* Removed the call to Renderer2 as it wasn't needed
2024-07-11 09:04:51 -04:00

18 lines
484 B
TypeScript

import { Directive, ElementRef, HostListener, Self } from "@angular/core";
import { NgControl } from "@angular/forms";
@Directive({
selector: "input[appInputStripSpaces]",
})
export class InputStripSpacesDirective {
constructor(
private el: ElementRef<HTMLInputElement>,
@Self() private ngControl: NgControl,
) {}
@HostListener("input") onInput() {
const value = this.el.nativeElement.value.replace(/\s+/g, "");
this.ngControl.control.setValue(value);
}
}