I am trying to make form validation in angular it is not working.
html:
<div>
<form [formGroup]="form" action="javascript:void(0)" (submit)="send()" method="POST">
<input formControlName="from_name" name="from_name" type="text" placeholder="Full Name"/>
<input formControlName="from_email" name="from_email" type="text" placeholder="Email Address"/>
<input formControlName="subject" name="subject" type="text" placeholder="{{this.property.Name}} in {{this.property.City}}"/>
<textarea formControlName="message" name="message" type="text" placeholder="Enter your message"></textarea>
<button id="clickit" class="button1" type="submit">Submit</button>
</form>
</div>
in ts:
form: FormGroup = this.fb.group({
from_name: ['', Validators.required],
to_name: ['Admin', Validators.required],
from_email: ['', Validators.required],
subject: ['', Validators.required],
message: ['', Validators.required],
});
if i click the button it is submitted even if i have some fields empty!