72 questions
1
vote
1
answer
106
views
Form Control Angular Hide/Show Form Field
I have a reactive form that I want to show in steps. When the first field is validated, the form will show the next field. Being new to Angular the form works in some cases. The problems arise when a ...
1
vote
1
answer
43
views
Customize third party directive's implementation without forking
In our Angular project we are using @ngneat/error-tailor for showing form errors:
We are interested in showing the error messages when the controls are touched, feature which is requested in this ...
0
votes
1
answer
174
views
Angular- Reactive Form data not getting saved
I was working on a project with reactive forms. There I added a button 'Submit', clicking which the form was supposed to get submitted. There is also an anchor tag clicking which new fields get added. ...
0
votes
1
answer
784
views
Async validation message not displaying in ngx-formly
When trying this example from the ngx-formly library, the message that comes from the async validation is not displaying under the field as exprected
https://formly.dev/docs/examples/validation/unique-...
0
votes
3
answers
2k
views
How Remove custom Validators with method RemoveValidators
I have a question how can I remove my custom validators in the easiest/best way?
I know that since angular 12 there is a method RemoveValidators, it is based on the reference of a given validator, ...
0
votes
1
answer
5k
views
Angular removing Validators.min from form control validation
I have a form with 2 fields:
includeValidation, a select dropdown (2 option): with validation, without validation
amount, an input number field
depending on the first dropdown I have validators on ...
0
votes
1
answer
1k
views
Angular: disable field on change and set value of field
I have a table in which I need to render database values and then after user changes I need to submit that form. Here is demo
There I need to apply like,
if status is 'eliminated' or 'absent' then ...
0
votes
1
answer
173
views
Angular 2+ Custom form validation breaks the form methods
I have a form:
public buildUserForm(user: User = null): void {
this.selectedUserForm = this.fb.group({
id: 0,
isActive: [true],
isSuperUser: [null],
firstName: ['', ...
1
vote
0
answers
966
views
NG0301: Export of name 'ngModel' not found
in the below code i wanted to perform reactive form validation. so i referred to some questions and tutorial for example this one:
https://jasonwatmore.com/post/2018/05/10/angular-6-reactive-forms-...
1
vote
3
answers
3k
views
Angular Form Validation - hasError min doesnt work
I want to show an error if the value is 0 but it doesnt work.
HTML:
<mat-form-field>
<input matInput type="number" placeholder="{{ 'device.new.windowHeight' | translate }}...
0
votes
1
answer
4k
views
Angular form validation - display error in another row/div
The current error message displays just below the text box. But I want to display it in the entire row below to the label and text box
I tried it by moving the div like below, but it doesn't work. I ...
4
votes
2
answers
6k
views
Angular FormBuilder group is deprecated [duplicate]
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 ...
6
votes
1
answer
6k
views
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 ...
4
votes
1
answer
5k
views
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, "...
1
vote
1
answer
2k
views
How to trigger form validations (only) when submitting the form?
I created a dynamic form, in which you can add or remove fields with dedicated buttons:
The problem is that when we add a new field, the form validations are immediately triggered causing the error ...
0
votes
1
answer
1k
views
How to add form validation from a list of items in Angular
I have a reactive form with validation and I'm trying to figure out how to add an additional check to a list of items. ex. I want at least one item to be checked for the form to be valid in addition ...
1
vote
1
answer
6k
views
Angular Reactive Forms: How to display an error+red border?
I'm starting to use Angular Reactive Forms.
I really like the idea of being able to have async validator(for things that have to check something against the DB), and I like the idea that the GUI doesn'...
1
vote
0
answers
148
views
How to correctly set up Angular2 template-driven form validation for min/max?
I'm trying to implement a new Angular component with template-driven form validation. I have been following the documentation here, but cannot seem to replicate the results. Specifically, the div ...
6
votes
2
answers
1k
views
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 ...
0
votes
1
answer
1k
views
Form field validation not working Angular 8
I am validating a form field which is created dynamically. I basically have three validations in place:
1. Value inputted should be between 0-10
2. Only numbers should be allowed
3. As the value is ...
0
votes
1
answer
2k
views
How to custom validate FormArray
I'm building a reactive form with a FormArray which has FormGroups inside. Each FormGroup has 3 controls, from which two are dropdowns. I'd like to prevent the user to choose the same option multiple ...
0
votes
0
answers
206
views
Custom Formcomponent with ControlValueAccessor/Validator has asynchronous update of control inside validate
Inside my angular app I generated a component that serves as a custom FormControl and it implements ControlValueAccessor and Validator.
That component is used inside a FormGroup and it has a ...
0
votes
0
answers
462
views
How can i Append a html code to the input field from custom directive in angular
i am trying to show errors for the fields in angular forms:
i am able to get the error when we make a changes in the form field and print it in the console but i am not able to append that into the ...
3
votes
1
answer
15k
views
Angular Reactive Form Validation: Do not allow a number less than existing number
I have a numeric input field in Angular reactive form.
<input id="referenceNumber" type="number" formControlName="referenceNumber" />
<div *ngIf="form.referenceNumber.invalid && (...
0
votes
2
answers
2k
views
Dynamic validation based on conditions
Scenario: I have 4 form fields.
Description (Optional)
Select Type (Required)
Phone (Required only if Select Type is set to 'Phone')
Email (Required only if Select Type is set to 'Email')
When I ...
2
votes
1
answer
7k
views
Form validations with ngModel and ngModelOption in angular 8
I'm using angular 8 with formGroup and formController for validation which works great through reactive as well as template-driven form.
However, I was trying to use "ngModel" in angular 8 with "...
2
votes
1
answer
11k
views
Angular, is there a way to "markAsTouched" a field without a Form?
I've already know that input items inside a FormControl can be mark dirt or touched by calling any of the following methods (maybe more): group.markAsTouched(); form.get('control-name').markAsTouched(...
0
votes
1
answer
648
views
How to separate 'Implemented Conditional Validation Service/Function' in Angular-8 while using Reactive-Forms
I have implemented conditional Validation in my Component.
I am trying to separate the validation logic from my component to another component/service.
Demo Link : http://StackBlitz%20https://...
0
votes
2
answers
2k
views
Angular reactive forms form-group validations are working only for any one row in Mat-table
I have Mat table with multiple rows, with add button ,on click of it, adds a new row. i want to add validations for all the rows ,right now my code below is taking a validation only for any one row.
...
0
votes
1
answer
1k
views
form async validation when updateOn is blur, to subscribe statusChanges or valueChanges
I am using form async validation with updatOn: 'blur' in my Angular7 application.
stackblitz
in this situation, I need to check if the name is unique(async validation).
this.myForm.get('name')....
0
votes
1
answer
2k
views
How to change form status manually? Or what to do before reassign a form?
For some reason I have to change a form status manually.
In my case, if form validation failed, I can click a refresh button, and then the form will be initiate again. But the validation failed ...
0
votes
1
answer
432
views
Angular form validation failed, caused some problems?
I have this form or formarray and book model:
class Book {
id: number;
active: boolean;
name: string;
}
bookForm: FormGroup;
results: Book[];
ngOnInit() {
this.results = [
{id: 1, ...
1
vote
3
answers
12k
views
how to trigger validation and get validation result after submit form action in Angular?
I have this formgroup:
this.form = this.fb.group({
id: [],
active: [true],
name: [''],
});
and this submit form function:
onSubmit(submitForm: FormGroup) {
this.submitForm.controls['name']....
2
votes
2
answers
16k
views
How to validate formarray in angular?
I'm using editable with formarray.
My model:
class Book {
id: number;
name: string;
active: boolean;
}
allBooks:
[
{id: 1, name: 'book1', active: true},
{id: 2, name: 'book2', active: true},
...
2
votes
1
answer
861
views
How to prevent form submit until all validations are passed [Angular 7]
I am new to Angular. I have read this, this and this question thoroughly, But none of them are of my use as they are using jquery. My form is pretty basic registration form with only 4 basic fields. ...
2
votes
2
answers
12k
views
Angular Reactive Forms - Perform Validation After Form Fields Shown / Hidden on Value Changes
I'm working with reactive forms with various required fields to validate. Certain fields have conditional validation that should only be checked if the conditions are met. (i.e. If you answered yes to ...
0
votes
3
answers
3k
views
Reactive form validation using asynchronous validation and Ngrx store
I'm developing an Angular 8 application. I want to display form errors using NgRx store and reactive forms using a custom asynchronous validator.
login.component.ts
@Component({
selector: 'auth-...
2
votes
1
answer
2k
views
Angular ValidatorFn returns, but does not block Form
I have build a Custom Validator for my Form, which returns expected ValidationErrors object.
ValidateDirectory(clientId: string): ValidatorFn {
return (control: AbstractControl): ...
1
vote
1
answer
454
views
How to show a custom error message on entering an email input field with other than english language (like arabic)
We have a application with supporting two languages (english,arabic) and in the registration form we need to support both the languages. But only for email field we need to show error message use ...
0
votes
0
answers
374
views
How to validate dynamic ion-input in ion-list in IONIC 3
I have a ion-list, where I have two ion-items in it. In ion-items I have ion-input which will be dynamically added
on click of add button. I want to validate each ion-input ,
below is my code.
<...
0
votes
1
answer
801
views
Angular Reactive Forms Buttons with different validations
I was thinking of doing a simple form with reactive forms.
The problem I think I'm going to have is when I have two buttons on the form which will need different validation.
For Example, Andy ...
0
votes
2
answers
1k
views
Set dynamic ValidationFn in reactive form formgroup
I'm trying to create a very generic\dynamic reactive form which can use a custom Validation Function for a formgroup (to compare 2 dates). The function can actually be any validation function which is ...
1
vote
4
answers
4k
views
Angular 7 + Angular Material => Form Validation Error not appearing until leaves focus
<form (ngSubmit)="saveChanges()">
<mat-form-field appearance="outline" >
<mat-label>New ID</mat-label>
<input required matInput name="newName" [style]="...
5
votes
1
answer
1k
views
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 ...
1
vote
1
answer
651
views
Angular Hybrid Application Form Validation
Im upgrading a AngularJS app to Angular5.
Im migrating some components from AngularJS to Angular5, but not all the other windows of the app that use ng-form to form validation.
<div class="form-...
1
vote
1
answer
3k
views
How to perform conditional validation in html Angular form
I have a form where I want to implement the MAXLENGTH validation only if the value is not equal to 0.
So if parameter.valueMaxlength === 0 { then dont execute maxlength validation }
Is there a way ...
2
votes
1
answer
1k
views
How to dynamically create FromGroup from an observable?
I am creating this page that suppose to contain multiple reactive froms (for each country for example). These forms should be create base on the the json array i get from the back end so user can see ...
2
votes
3
answers
20k
views
select option with default value undefined with required attribute does not work but value empty
I have a dropdown of countries
<select #countryInput name="country" [(ngModel)]="room.countryId" required>
<option [selected] [value]="undefined">Select Country</option>
&...
0
votes
2
answers
647
views
Calling validate function before submiting the form using ngNativeValidate
I am trying to call the validate(ngNativeValidate) function on click of button.
My form look like:
<form #myForm="ngForm" (ngSubmit)="addEndpoint(myForm.value);" ...
0
votes
1
answer
56
views
How can we show form error validations one after one in Angular
I am new for angular and i have created one Custom EmailDomainError validator class and its working fine.
But problem is Email domain Error is showing along with Email validation error message how ...