Created
May 23, 2019 15:38
-
-
Save fnnzzz/2d7f4d3f34efbf35f24c682beef9ec44 to your computer and use it in GitHub Desktop.
angular form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public acmeControl = new FormControl('', [Validators.required, Validators.pattern(constants.EMAIL_PATTERN)]) | |
this.fb.group({ | |
acme: this.acmeControl, | |
}) | |
/////////////// | |
<form novalidate [formGroup]="fooForm"> | |
<div class="input-block" [class.filled]="acmeControl.value.length"> | |
<input type="text" id="acme" name="acme" [formControl]="emailControl" /> | |
<label for="acme">Email:</label> | |
</div> | |
<div class="error-box fsize12" *ngIf="!acmeControl.valid && acmeControl.dirty && acmeControl.touched"> | |
<p *ngIf="acmeControl.hasError('required')"> | |
{{ l.translations.errorMessages.requiredField }} | |
</p> | |
<p *ngIf="acmeControl.hasError('pattern')"> | |
{{ l.translations.errorMessages.invalidFieldEmail }} | |
</p> | |
</div> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment