Skip to content

Commit

Permalink
Validations: Date, No of customers, price, text area #16
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraagrijal3138 committed Apr 17, 2018
1 parent 8285963 commit e5fea8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/app/post-cuisine/post-cuisine.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ <h1>Post Cuisine</h1>
<mat-label>Cuisine Name</mat-label>
<input matInput
formControlName="cuisineName">
<mat-error>This field is required</mat-error>
</mat-form-field>

<mat-form-field
class="full-width">
<mat-label>Description</mat-label>
<input matInput formControlName="description">
<textarea matInput matTextareaAutosize
matAutosizeMaxRows="5" formControlName="description"></textarea>
<!-- <input matInput formControlName="description"> -->
<mat-error>This field is required</mat-error>
</mat-form-field>

<mat-form-field
class="full-width">
<mat-label>Hosting Date</mat-label>
<input matInput type="date" formControlName="hostingDate">
<input matInput type="date" [min]="utc" formControlName="hostingDate">
<mat-error>This field is required</mat-error>
</mat-form-field>

Expand All @@ -45,7 +46,8 @@ <h1>Post Cuisine</h1>
<mat-form-field
class="full-width">
<mat-label>Price</mat-label>
<input matInput formControlName="price">
<input matInput type="number" formControlName="price">
<span matPrefix>$&nbsp;</span>
<mat-error>This field is required</mat-error>
</mat-form-field>
<div>
Expand Down Expand Up @@ -105,7 +107,7 @@ <h1>Post Cuisine</h1>
<ng-template matStepLabel>Number of Accomodations</ng-template>
<mat-form-field>
<mat-label>Number of customers</mat-label>
<input matInput formControlName="numberCust" min="1">
<input matInput type="number" formControlName="numberCust">
</mat-form-field>
<div>
<button type="button" mat-button (click)="linearVerticalStepper.reset()">Reset</button>
Expand Down
11 changes: 7 additions & 4 deletions src/app/post-cuisine/post-cuisine.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ import { AuthService } from '../auth.service';
export class PostCuisineComponent implements OnInit{
formGroup: FormGroup;
files: FileList;

utc: string;
/** Returns a FormArray with the name 'formArray'. */
get formArray(): AbstractControl | null { return this.formGroup.get('formArray'); }

constructor(private _formBuilder: FormBuilder,private authService: AuthService,
private router: Router ) { }
private router: Router ) {
this.utc = new Date().toJSON().slice(0,10).replace(/-/g,'-');
console.log(this.utc);
}

ngOnInit() {
this.formGroup = this._formBuilder.group({
Expand All @@ -30,12 +33,12 @@ export class PostCuisineComponent implements OnInit{
description: ['', Validators.required],
hostingDate: ['', Validators.required],
hostingTime: ['', Validators.required],
price: ['', Validators.required]
price: ['', Validators.required ]
}),
this._formBuilder.group({
dormName: ['', Validators.required],
streetAddress1: ['', Validators.required],
streetAddress2: ['', Validators.required],
streetAddress2: [''],
cityName: ['', Validators.required],
stateName: ['', Validators.required]
}),
Expand Down

0 comments on commit e5fea8f

Please sign in to comment.