import { Component, OnInit } from '@angular/core';
import { FormBuilder,Validators } from '@angular/forms';
import { NgForm } from '@angular/forms';

@Component({
  selector: 'app-contact-us',
  templateUrl: './contact-us.component.html',
  styleUrls: ['./contact-us.component.css']
})
export class ContactUsComponent implements OnInit {

	public contactForm;
	public showMessage: boolean = false;
	public invalidEntry = 'Invalid entry';

	userName = '';
  	email: string;
  	password: string;
  	textArea: string;

  constructor(private formBuilder: FormBuilder) { }
  ngOnInit(): void {
    this.contactForm = this.formBuilder.group({
      firstName: ['', [Validators.required,Validators.pattern('^[a-zA-Z]+$')]],
      lastName: ['',[ Validators.required,Validators.pattern('^[a-zA-Z]+$')]],
      email: ['', [ Validators.required,Validators.pattern('[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}')]],
      comments: ['']
    });
  }
  onSubmit(){
		return this.contactForm.valid ? alert('User form is valid!!') : alert('User form is not valid!!')
  }
}
