Questions tagged [angular-validator]

64 questions
18
votes
7 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…
10
votes
2 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
  • 6,750
  • 23
  • 130
  • 288
6
votes
1 answer

Angular reactive form, Dynamic validator not updating control validity

So I have a form where a control is required only if another control has a value, for this I created the following structure profileGroup = this.fb.group({ username: [''], address: [ '', [ (control: AbstractControl) => { if…
6
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…
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

How do you determine which validator condition failed in angular 8

for example I have an input , and I add muti validate conditions like: required , mail and pattern , so any one failed will lead the controls.status gave me "INVALID" , what shall I do if I want to know which one is failed?
Shinji035
  • 331
  • 2
  • 6
  • 17
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
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({ …
PacMan Programador
  • 191
  • 1
  • 2
  • 14
3
votes
2 answers

Custom validator for date before in angular

I want to write a custom dateValidator with reactive forms to check if an inputed date is before today. Component.html
...
jtobelem
  • 749
  • 2
  • 6
  • 23
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…
SKL
  • 1,243
  • 4
  • 32
  • 53
2
votes
1 answer

How to custom validate two text boxes with a regular expression /^[1-9]\d*$/?

I'm trying to write a custom validator for 2 text boxes, with some conditions. Please see the code I wrote in Stackblitz Link to validate the text boxes with some conditions Kindly help me where did I go wrong.
2
votes
1 answer

Async validator not executing

Stackblitz: https://angular-ivy-mhot2x.stackblitz.io For my Angular (13.0.2) application, I've created a validator to check if a URL is already in use (i.e. GET does not return 404). However, while I can see the function being called, I don't…
Aurelia Peters
  • 2,169
  • 1
  • 20
  • 34
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
5 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...
  • 3,104
  • 10
  • 58
  • 96
1
2 3 4 5