0

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('');
      });
  }

1 Answer 1

1

Try to use like this -

  <button [disabled]="disabledAgreement && !user.valid ">Sign Up</button>
Sign up to request clarification or add additional context in comments.

2 Comments

suppose I want to do the same EXCEPT ONE FIELD ( REFRAL CODE FIELD) then !user.valid is not working
Seems in that case you need to manually check for each each field's validation and disabled your button

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.