Questions tagged [angular2-form-validation]
72 questions
27
votes
7 answers
Angular FormArray display validation errors
I have Angular form that is built with help of FormBuilder.
Form contains a FormArray which has as many fields as user wants. I've set validator for fields
this.fb.array([this.fb.control('', Validators.required)])
and for each new push validator is…

Sergey
- 7,184
- 13
- 42
- 85
10
votes
5 answers
at least one field is required in angular 4 forms
I'm using angular 4 forms and I have some fields. and first_name, last_name and company are really important for me. I want to force the user to fill one of these 3 fields. how can I do it?
here are .ts codes:
this.contactForm = this.fb.group({
…

fariba.j
- 1,737
- 7
- 23
- 42
6
votes
2 answers
Angular calls a validation function for many times
I have angular form.
When I open the app, the console is log in fooValidation four times without me don't nothing.
in fooValidation
in fooValidation
in fooValidation
in fooValidation
Why? This is it by design? how to make it execute only after the…

Jon Sud
- 10,211
- 17
- 76
- 174
5
votes
1 answer
How to fix: Angular 7 (SmartAdmin template) form validation stops working after navigation
I am trying to perform form validation on an angular 7 app that is using the Smart Admin Template (Theme from wrapbootstrap).
My issue is that it is working as expected the first time the browser refreshes, or even when i navigate to a component…
5
votes
3 answers
Angular ng select required option
I cannot find out how to use the required option in ng-select.
I have tried this:

Iraklis
- 208
- 1
- 5
- 16
5
votes
1 answer
Is it possible to pass dynamic values to a custom form validator in Angular 6?
basically, i have some form inputs whose validations are dependent on each other (i.e. if you're putting in a time range, the "from" time must be smaller than the "to" time) but i'm not exactly sure how to go about this.
Here is my form…

philr
- 1,860
- 1
- 21
- 31
4
votes
1 answer
Angular reactive form validation with dynamically named controls
In my Angular 7 app using reactive forms I'm creating input elements based on an *ngFor loop, so I end up with an input dynamically named:

Gargoyle
- 9,590
- 16
- 80
- 145
3
votes
2 answers
Angular FormBuilder group is deprecated
I saw there is a topic which looks like mine but it doesn't really answer my problem because we don't manage the errors in the same way. FormBuilder group is deprecated
First of all, I just migrated to Angular 11 and I have this problem now:
group…

user3659739
- 434
- 6
- 19
3
votes
1 answer
async validator (AsyncValidatorFn) is never subscribed to
I wrote a custom Form Validator but in errors it just has "_isScalar": false, "source": { "_isScalar": false, "source": { "_isScalar": false, "source": {"_isScalar": false}, "operator": {}}, "operator": {"total": 1} and the form is never…

Andresch Serj
- 35,217
- 15
- 59
- 101
3
votes
1 answer
Angular Reactive Form Validation: Do not allow a number less than existing number
I have a numeric input field in Angular reactive form.
…

Madhur Maurya
- 1,016
- 4
- 19
- 42
3
votes
1 answer
Angular 5 Form validation on form array fields
I am working on a project where I want to put required validation on a form array field.
Here is my template

Neeraj Sharma
- 311
- 2
- 4
- 13
3
votes
1 answer
Angular 6 reactive form validation not working with custom validator
So I created a custom validator to validate that a "New Password" field and a "Confirm Password" field match. On the component level, it works great. The error message only shows when the two inputs don't match.
The problem is, I disable the submit…

Mr Shantastic
- 510
- 1
- 7
- 16
3
votes
1 answer
Angular 6 form returns validation error after submit and reset
I'm using angular 6 and I have a form and a button. When I press the button the app shows the form data above the form and I call form.reset(). But after form reset the input fields become red because I set the fields required in my form. Where is…

fariba.j
- 1,737
- 7
- 23
- 42
3
votes
2 answers
How to show different validation messages for email validation in Angular2 using Validators class?
I am using FormGroup, FormBuilder and Validators class to validate a form in Angular2 app.
This is how I am defining the required validation rules for email and password validation:-
export class LoginComponent implements OnInit {
…

Saswat
- 12,320
- 16
- 77
- 156
2
votes
1 answer
When and where to call updateValueAndValidity?
I'm unclear on when and where exactly I should be calling the updateValueAndValidity.
Let's say I have a formGroup with many formControls.
Now, based on some radio option selection an event fires to modify the 'validators' for several…

edjm
- 4,830
- 7
- 36
- 65