Questions tagged angular-validation

Explore the latest questions and answers asked by our top developers.

A contact form in angular is crashing with error Error: NG0201: No provider for NgControl found in NodeInjector

I used an interface for the form inputs in an angular project, I have imported the interface in the contact.component.ts file and imported FormsModule in the app.module.ts there are no compilation errors but the contact page does not show when I try to view it. I would appreciate helpful responses. I also have issues with […]

Angular Validation Status of ngModelGroup

I have one parent Angular Form that I wish to use in a number of sub components. To do this, I instruct my sub component to reuse the parent form: viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] Within my sub component, I have created a new ngModelGroup. The whole form shoudn’t be valid until all […]

By illwalkwithyou
Categorized as angular, angular-validation Tagged ,

Angular 11 Custom ISBN Validator Reactive Forms

I’m doing a custom validation for an ISBN number, I already have the function that checks the number and works perfect giving me the response by console, but I need to do the custom validator to get the error in the view with the form control and in this step this error is showing in […]

Angular incorrectly setting input class as valid

I have this input field <input formControlName="fieldName" class="validate" id="fieldName" type="text"> <label for="fieldName">{{field.fieldLabel}}</label> <ng-container *ngIf="myForm.controls.fieldName.touched && myForm.controls.fieldName.invalid"> <span class="helper-text" data-error="Error message" *ngIf="myForm.controls.fieldName.errors.pattern"></span> </ng-container> When I inspect it in console, before typing anything, I get this: <input _ngcontent-lqx-c2="" class="validate ng-untouched ng-pristine ng-valid" formcontrolname="fieldName" id="fieldName" type="text" ng-reflect-name="fieldName"> After I type a wrong value, I get this: <input _ngcontent-lqx-c2="" […]

Angular forms require one form group to be valid

I am trying to implement a reactive angular form where either A or B has to be entered. A is a unique id and B is a set of values which identify the id. Now I try to validate a Form that is valid if either A is entered or B is entered including all […]

only decimal number and prevent other language in Angular

I want input only accept number decimal, but when i change keyboard to other languages (e.g chinese..) and type text character, it’s back to normal , how to prevent it?, thanks @Directive({ selector: ‘[numeric]’ }) export class NumericDirective { @Input(‘decimals’) decimals: number = 0; private check(value: string, decimals: number) { if (decimals <= 0) { […]

Angular validator: How to unsubscribe to valueChanges from parent component?

Using Angular 11 I have a regular component with several form controls like so, and with all the validators in a separate file to keep things clean. In some of the validator functions, I’m subscribing to the valueChanges event on certain controls. I’m wondering how I can unsubscribe to those subscriptions when the parent component […]

Angular regex pattern validator always setting ng-invalid class [closed]

I am trying to validate a password field like this password: new FormControl(”, Validators.pattern(‘^((?=.*d)(?=.*[A-Z])(?=.*W).{8,})$’)), But everytime I write the correct password the class is set to ng-invalid. I need: At least 8 characters At least 1 numeric character At least 1 special character At least 1 uppercase character So fe. ABC123() should work, but it […]

Only one filed form validation is working in angular js

I’m creating a login and registration page using MEAN stack. My registration form validation is not working. Only the first one is working; the rest of the fields are not showing anything. In addition to that, when the form is submitted, data is passed to the database, but it does not show the success message […]

Angular- How to add validators to a reusable input component?

I have made a reusable input component. Which I used inside a table. Now I want to add different(or same) validators in those input fields. How do I do it? This is the stackblitz link of the project, for helping in better understanding. Source: Angular Questions

1 8

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us