Last active
September 30, 2020 14:30
-
-
Save vorpal56/c5438234f40df7578e6ded4f80054938 to your computer and use it in GitHub Desktop.
Contact form without a server using Angular - contact.component.html with Material
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
<form class="contact" [formGroup]="form" method="post" (ngSubmit)="onSubmit()"> | |
<mat-form-field> | |
<mat-label>Name</mat-label> | |
<input matInput [formControl]="name" required> | |
<mat-error *ngIf="name.invalid">Please enter your name</mat-error> | |
</mat-form-field> | |
<mat-form-field> | |
<mat-label>Email</mat-label> | |
<input matInput [formControl]="email" placeholder="email@example.com" required> | |
<mat-error *ngIf="email.invalid">Please enter a valid email</mat-error> | |
</mat-form-field> | |
<mat-form-field> | |
<mat-label>Message</mat-label> | |
<textarea matInput [formControl]="message" maxlength="256" placeholder="I'm interested in..." required></textarea> | |
<mat-hint align="end"> {{message.value?.length || 0}}/256</mat-hint> | |
<mat-error *ngIf="message.invalid">Please enter a message</mat-error> | |
</mat-form-field> | |
<button [disabled]="isLoading" class="submit" type="submit">Submit</button> | |
<input [formControl]="honeypot" class="hidden" type="text" /> | |
<div [ngClass]="!submitted? 'hidden' : 'visible'" class="center-text"> | |
<span>{{responseMessage}}</span> | |
</div> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment