Siddharth Gautam
Siddharth Gautam

Reputation: 115

How do I disable the Submit button until the input fields conditions are met?

I need the submit button to be disabled until all the form fields are filled. I have done the following in HTML file:

<button dlsButton class="pt-primary adconfig-button" (click)="testConnection()" 
[disabled]="!adForm.form.valid" i18n>Test Connection</button>

and this in TS file:

this.adForm = this.formBuilder.group({
        DnsDomain: ['', [Validators.required], [Validators.minLength(1)]],
        UserName: ['', [Validators.required], [Validators.minLength(1)]],
        Password: ['', [Validators.required], [Validators.minLength(1)]],
    });

how can I make the button disabled it is still enable now

Upvotes: 0

Views: 208

Answers (1)

G&#233;r&#244;me Grignon
G&#233;r&#244;me Grignon

Reputation: 4238

change [disabled]="!adForm.form.valid" to [disabled]="!adForm.valid"

Upvotes: 1

Related Questions