Commit ff56f46f authored by ccottier's avatar ccottier

friendly validations added

parent cdd25a01
...@@ -22,9 +22,13 @@ ...@@ -22,9 +22,13 @@
</div> </div>
</form> </form>
<div > <div >
<ngb-alert *ngIf="showMessage" type="danger" >{{ invalidEntry }}</ngb-alert> <ngb-alert *ngIf="showInvalidMessage" type="danger" >{{ invalidEntry }}</ngb-alert>
<div class= "invalid-text" *ngIf="showMessage"> <!-- <div class= "invalid-text" *ngIf="showInvalidMessage">
{{invalidEntry}} {{invalidEntry}}
</div> </div> -->
<ngb-alert *ngIf="showValidMessage" type="success" >{{ validEntry }}</ngb-alert>
<!-- <div class= "valid-text" *ngIf="showValidMessage">
{{validEntry}}
</div> -->
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -9,8 +9,12 @@ import { Component, OnInit } from '@angular/core'; ...@@ -9,8 +9,12 @@ import { Component, OnInit } from '@angular/core';
export class ContactUsComponent implements OnInit { export class ContactUsComponent implements OnInit {
public userForm; public userForm;
public showMessage: boolean = false;
public invalidEntry = 'Invalid entry'; public showInvalidMessage: boolean = false;
public invalidEntry = 'Invalid entry!';
public showValidMessage: boolean = false;
public validEntry = 'Valid Entry!'
constructor(private formBuilder: FormBuilder) { } constructor(private formBuilder: FormBuilder) { }
ngOnInit(): void { ngOnInit(): void {
...@@ -24,9 +28,11 @@ export class ContactUsComponent implements OnInit { ...@@ -24,9 +28,11 @@ export class ContactUsComponent implements OnInit {
onSubmit(){ onSubmit(){
if(this.userForm.valid){ if(this.userForm.valid){
alert('User form is valid!!') this.showInvalidMessage = false;
this.showValidMessage = true;
} else { } else {
alert('User form is not valid!!') this.showInvalidMessage = true;
this.showValidMessage = false;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment