Fairoj: Emp form net sal max validation is done

This commit is contained in:
venbatechnologies@gmail.com 2020-01-08 15:39:47 +05:30
parent 6d31845961
commit d71e5f9168
2 changed files with 8 additions and 1 deletions

View File

@ -214,7 +214,7 @@
</mat-form-field> -->
<mat-form-field style="width: 80%">
<input matInput placeholder="Gross Monthly Salary" formControlName="gross_monthly_salary"
OnlyNumber type="text" autocomplete="off" required>
OnlyNumber type="text" autocomplete="off" required (change)="setValidationForNetSal($event.target.value)">
<mat-hint align="start" style="font-size:90%" *ngIf="employmentForm.controls['gross_monthly_salary'].value != ''">{{"&#8377;"}} {{employmentForm.controls['gross_monthly_salary'].value | numberToWords}} Only</mat-hint>
<mat-error *ngIf="employmentForm.controls['gross_monthly_salary'].hasError('required')">Gross Monthly Salary Required</mat-error>
</mat-form-field>
@ -224,6 +224,7 @@
OnlyNumber type="text" autocomplete="off" required>
<mat-hint align="start" style="font-size:90%" *ngIf="employmentForm.controls['net_monthly_salary'].value != ''">{{"&#8377;"}} {{employmentForm.controls['net_monthly_salary'].value | numberToWords}} Only</mat-hint>
<mat-error *ngIf="employmentForm.controls['net_monthly_salary'].hasError('required')">Net Monthly Salary Required</mat-error>
<mat-error *ngIf="employmentForm.controls['net_monthly_salary'].hasError('max')">Given value is More than Gross Monthly Salary</mat-error>
<!-- <input matInput placeholder="Net Take Home"
formControlName="net_take_home"> -->
</mat-form-field>

View File

@ -164,6 +164,7 @@ export class EmploymentInfoComponent implements OnInit {
this.employmentForm.controls['to_date_the_salary_is_rcv'].setValue(value.records.to_date_the_salary_is_rcv);
this.employmentForm.controls['gross_monthly_salary'].setValue(value.records.gross_monthly_salary);
this.employmentForm.controls['net_monthly_salary'].setValue(value.records.net_monthly_salary);
this.setValidationForNetSal(value.records.gross_monthly_salary)
this.employmentForm.controls['mode_of_getting_salary'].setValue(value.records.mode_of_getting_salary);
if(value.records.mode_of_getting_salary == 'both_bank_transfer_cash'){
this.employmentForm.controls['amount_paid_in_cash'].setValue(value.records.amount_paid_in_cash);
@ -693,4 +694,9 @@ export class EmploymentInfoComponent implements OnInit {
}
});
}*/
setValidationForNetSal(value){
console.log(value)
this.employmentForm.controls['net_monthly_salary'].setValidators([Validators.max(value),Validators.min(0)]);
this.employmentForm.controls['net_monthly_salary'].updateValueAndValidity();
}
}