From 99287dff749f7c6fa050b597115270496738d77c Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Sun, 8 Dec 2019 15:38:08 -0500 Subject: Add basic input validation to add recipe form Validates: Name is required, Timer/Cook Time are digits, Amount/Servings are numbers (digits with optional decimal point). --- recipeBuddy/src/app/add-recipe/add-recipe.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'recipeBuddy/src/app/add-recipe/add-recipe.component.ts') diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts index b4f4d1e..50ea1cd 100644 --- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts +++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts @@ -26,7 +26,7 @@ export class AddRecipeComponent { ingredients: this.fb.array([ this.fb.group({ ingrName: [''], - amount: [''], + amount: ['', Validators.pattern('^[0-9]*(\.[0-9]*)?$')], units: [''] }) ]), @@ -36,8 +36,8 @@ export class AddRecipeComponent { timer: [''] }) ]), - servingSize: [''], - cookTime: [''], + servingSize: ['', Validators.pattern('^[0-9]*(\.[0-9]*)?$')], + cookTime: ['', Validators.pattern('^[0-9]*$')], tags: [''], photos: [''] }); @@ -57,7 +57,7 @@ export class AddRecipeComponent { this.ingredients.push( this.fb.group({ ingrName: [''], - amount: [''], + amount: ['', Validators.pattern('^[0-9]*(\.[0-9]*)?$')], units: [''] }) ); @@ -75,7 +75,7 @@ export class AddRecipeComponent { this.steps.push( this.fb.group({ instruct: [''], - timer: [''] + timer: ['', Validators.pattern('^[0-9]*$')] }) ); } -- cgit v1.1