Questions tagged [angular-validator]

53 questions
8
votes
5 answers

Angular 6, this.formGroup.updateValueAndValidity() not working properly

I am trying to add and remove validators in a formGroup controls based on certain condition. When I am updating the validators through formGroup.updateValueAndValidity() for whole form its not updating, where as if I am specifically applying for…
5
votes
2 answers

angular 5 validation date field using form builder

i have form and i want to validate date field on submit, i am using Form Builder, how can i do this(the angular way) ? another problem why i cant see the value published_date in the date field ? i tried to search and i can't find solution for input…
4
votes
2 answers

Angular 6 - reactive form validation pattern doesn't work

I have an Angular 6 reactive form and trying to validate a password with regex pattern and it doesn't work.
3
votes
1 answer

Angular material: How to set required validator as optional in reactive form

How to set required validator as optional is reactive form. I've two inputs amount and volume. if user choose amount radio button, required validation must be removed from volume input. If volume, required validation must removed from…
3
votes
3 answers

Angular 7 custom validation with dynamic/updated param

I am using angular 7 with material design components I have requirement to add requireMatch validation to mat-autocomplete. I have created custom validation with param but param value does change dynamically. Below is my component…
2
votes
3 answers

Dynamic password validator in angular 8

Hi I have an api that returns an array object passwordPolicy that contains PasswordMinLength: 6 passwordMinLowerCase: 1 passwordMinNumber: 1 passwordMinSymbol: 0 passwordMinUpperCase: 1 where the number can keep changing depending upon the role of…
2
votes
3 answers

How to make a Disabled Input also Required with Angular Reactive Form?

I have an input which will be populated when the user clicks on a dialog. So for this I had to make it disabled, because I don't want the user to manually input the value. The only problem is that this input must be required, and I couldn't make it…
2
votes
1 answer

applying pattern validator to input type number Angular 6

I have reactive form and one of the fields user can only enter positive non decimal number. this.projectForm = new FormGroup({ 'id': new FormControl(null, [Validators.required]), 'name': new FormControl(null, [Validators.required]), …
learning...
  • 2,759
  • 6
  • 51
  • 84
1
vote
2 answers

In reactive forms how do I create a custom validator that can validate an array of formGroup for no values?

I mean I have an order page that has a dynamic order items collection . I want to require the user to have atleast one item in that array. I understand simple usage of a custom validator but in this case I am not validating a single control but an…
punkouter
  • 4,690
  • 12
  • 57
  • 99
1
vote
1 answer

Multiple validator for call method in FormBuilder

I create a register form. There are two fields for password and email. In the second field from password and email I would like to check whether the first is the same as in the second. If I check just one, password or email, it works, but for both…
SwissCodeMen
  • 2,397
  • 3
  • 12
  • 21
1
vote
0 answers

Directive disappears when cancel button is pressed

I need to validate a date, so I create a directive validators: @Directive({ selector: ' input[id=datanint]', providers: [{ provide: NG_VALIDATORS, useExisting: DateValidatorDirective, multi: true }] }) export class DateValidatorDirective…
1
vote
3 answers

angular/forms integer validator

How can I validate my numeric input field to only accept integer and not any kind of decimal numbers (comma / dot)? Code Component import { FormGroup, FormBuilder, Validators } from '@angular/forms'; this.savingData = this.formBuilder.group({ …
mafortis
  • 5,003
  • 10
  • 59
  • 163
1
vote
3 answers

Activate angular validators only if input is visible

I'm trying to get this to work but I don't know how, I have several inputs that are only displayed when the user needs them.But if they are activated, it must be necessary to fill them. So i got this component.ts dataForm = new FormControl({ …
1
vote
0 answers

ReactiveForm force asyncValidator to be exec

I have a form with 3 fields. Country, City, Age. I have an asyncValidator on the group, to check if the City belongs to the Country (the validator will call a service, thats why he is asynchronous...). I display an error if this is false. And my 3…
Jax Teller
  • 1,329
  • 11
  • 19
1
vote
2 answers

Make all input field pristine after submitting once

I have an angular form, I want to mark all input fields pristine and submit button disabled after submitting once. Simply when this page loads for the first time like that.
1
2 3 4