All Questions
212 questions
1
vote
1
answer
37
views
Issue with activating validators on Angular reactive form at runtime - using form.updateValueAndValidity()
I have a simple yet perplexing problem.
I have a reactive form and I want to set validation programatically.
this.boatForm.get('boatType').setValidators(Validators.required);
this.boatForm....
1
vote
1
answer
162
views
Angular Validators.pattern() not working with type="number", works with type="text"
I've got the following input element for entering (part of) a phone number in an Angular 18 app with the associated Validators.pattern(/^[1-9]\d{5,}/):
...
form = this.formBuilder.group({
...
1
vote
1
answer
122
views
How to use updateValueAndValidity()
I have two form controls as min and max. At the beginning min has a default value of 1 and max is empty. I want that max be always greater than min, so I defined a custom validator, which works nicely....
1
vote
1
answer
103
views
How to customize date validation error messages in Angular?
I am working on an Angular form where I need to validate a date input field. Currently, if I enter a non-date text like "Date" in the field, I receive the error message "Date is ...
0
votes
1
answer
38
views
How to get a link to a subject in Angular?
I'm trying to write a directive that will be attached to a component and with this it will be possible to subscribe to its events. This directive should serve as a connector
@Component({
selector: ...
0
votes
1
answer
48
views
Custom control used with Validators.required in a reactive form control does not display the indicator
Let's say we have 2 inputs: MatInput control and custom input control.
<div [formGroup]="form">
<mat-form-field>
<mat-label>Phone number</mat-label>
<...
2
votes
1
answer
70
views
Angular form status validator 2
I'm trying to write custom form validator.
I have two component main-form and options. In options component I have list of checkboxes, and would like to validate, that on each row is checked at least ...
2
votes
2
answers
2k
views
Angular Reactive form: specify WHEN to validate
The conditional validator has probably been asked a lot. But what I could never find is when this validator is to be invoked.
Suppose I have a form with only two fields
this.form = formBuilder.group({
...
0
votes
2
answers
254
views
Angular form Validators.pattern does not work for matching 2 variants
I have a unique case where I have to validate either datetime format or empty string. Either of those should be valid input. But for example malformed or incomplete datetime should fail validation.
...
0
votes
1
answer
71
views
validator in angular reactive form not working properly?
I have this service, I am trying to validate the zip code field, but (result ? null : { IsInvalid: true }) never executes.
Is reactive form working properly or is it faulty logic/usage?
@Injectable({
...
0
votes
2
answers
127
views
Why angular form custom validation are not work?
**hello every one
I have angular project and for registration form inside it I create to filed one for password and another for confirmation password and I got two error
first one:**
ERROR TypeError: ...
0
votes
2
answers
335
views
How to style a div based on the validation status of the all included reactive form fields?
I have a relative complex form with a multiple fields.
Some of the fields a building the logical blocks, and I want to highlight the surrounding div if any of the included fields are invalid. What ...
1
vote
2
answers
1k
views
Allow input number only, else show message
Allowing the user to input number only is working.
But if the user tries to enter something other than number it must show message.
I have tried Validators with pattern, but I can't make the message ...
0
votes
2
answers
130
views
Form Validation from service.ts Angular
I need to add custom validators to a form from formvalidation.service.ts
form.component.ts
myForm = this.formBuilder.group({
name: ['', [Validators.required,]]
});
formvalidator.service.ts
...
2
votes
1
answer
428
views
Angular validator is stuck on pending
I am using Angular reactive form validation and on an the name input it remains stuck on pending after I pass the touched validation
I could not find any problem in the code itself or why the name ...