Testing Anurag
Testing Anurag

Reputation: 643

Disable button till all Input fields and checkbox is filled EXCEPT ONE FIELD

I am working in Angular 7 Where I am working with reactive form , I want to enable button only on all the Input field EXCEPT ONE FIELD (REFRAL CODE FIELD ) along with check box is filled , currently I am doing but but button is enables on checkbox check I am sharing my code ->

html

<form class="example-form" novalidate (ngSubmit)='user_signup(user)'  [formGroup]='user'>


                <input matInput placeholder="Email" value="" name='RegEmail' formControlName='RegEmail' [(ngModel)]="Email"/>

 <input matInput placeholder="Phone Number:" value="" name='RegPhone' formControlName='RegPhone' [(ngModel)]="Phone" OnlyNumber="true" maxlength="10" minlength="10" />

  <input matInput (input)="onInputTimePhone($event.target.value)" name="otpVerify" placeholder="Verify phone otp:" [(ngModel)]="otpVerify" value="" formControlName="otpVerify" />

   <input matInput placeholder="Enter Refer Code:" value="" name="ReferCode" [(ngModel)]="referCode" formControlName="ReferCode" />


  <mat-checkbox  (change)="changeCheck($event)">Resticted for below 18 years Playes or Players belonging from Orissa , Assam , Telangana </mat-checkbox>


          <button mdbBtn mdbWavesEffect class="register_btn" [disabled]="disabledAgreement && [user]='invalid' ">Sign Up</button>

</form>

ts file

constructor( public restapi:ServicesService , private logincomponent:LoginComponent) {
    this.user = new FormGroup({
      RegEmail: new FormControl('', [Validators.required,Validators.pattern("[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$")]);,
      RegPhone: new FormControl('', [Validators.required, Validators.minLength(10)]);,
       RegPassword: new FormControl('', [Validators.required, Validators.minLength(6)]),

       ReferCode:new FormControl('');
      });
  }

Upvotes: 0

Views: 760

Answers (1)

Pardeep Jain
Pardeep Jain

Reputation: 86730

Try to use like this -

  <button [disabled]="disabledAgreement && !user.valid ">Sign Up</button>

Upvotes: 1

Related Questions