From bf57d5eebf8b0fa2361b7973ce9772abd1bb4828 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 27 Nov 2016 18:10:26 +0100 Subject: Client: try to improve ux for the upload form --- client/src/app/shared/forms/form-reactive.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'client/src/app/shared/forms/form-reactive.ts') diff --git a/client/src/app/shared/forms/form-reactive.ts b/client/src/app/shared/forms/form-reactive.ts index 1e8a69771..a5732e083 100644 --- a/client/src/app/shared/forms/form-reactive.ts +++ b/client/src/app/shared/forms/form-reactive.ts @@ -21,4 +21,20 @@ export abstract class FormReactive { } } } + + // Same as onValueChanged but force checking even if the field is not dirty + protected forceCheck() { + for (const field in this.formErrors) { + // clear previous error message (if any) + this.formErrors[field] = ''; + const control = this.form.get(field); + + if (control && !control.valid) { + const messages = this.validationMessages[field]; + for (const key in control.errors) { + this.formErrors[field] += messages[key] + ' '; + } + } + } + } } -- cgit v1.2.3