This commit is contained in:
Venba 2024-07-08 16:28:50 +05:30
parent 70d9731525
commit 9d89a8ee4b
5 changed files with 42 additions and 7 deletions

View File

@ -30,17 +30,17 @@
<input formControlName="password" nbInput id="password" type="text" [status]="userForm.get('password').invalid && userForm.get('password').touched? 'danger' : 'basic'">
<ng-container nbInputErrorMessage>
<div style="color:#7c0e0e;font-size:small" *ngIf="!userForm.get('password')?.errors?.required && (userForm.get('password')?.errors?.pattern)">
Password length must be greater than or equal to 8
<div style="color:#7c0e0e" *ngIf="userForm.get('password')?.invalid && (userForm.get('password')?.dirty || userForm.get('password')?.touched) && userForm.get('password')?.errors?.required">
Password is required
</div>
<div style="color:#7c0e0e;font-size:12px;word-wrap: break-word;" *ngIf="!userForm.get('password')?.errors?.required && (userForm.get('password')?.errors?.pattern)">
Password length must be greater than or equal to 8 and password must contain one or more uppercase , lowercase , numeric and special characters
</div>
<!-- <div style="color:#7c0e0e" *ngIf="!userForm.get('password')?.errors?.required">
Password length must be greater than or equal to 8 and password must contain one or more uppercase , lowercase , numeric and special characters
</div> -->
<div style="color:#7c0e0e" *ngIf="userForm.get('password')?.invalid && (userForm.get('password')?.dirty || userForm.get('password')?.touched) && userForm.get('password')?.errors?.required">
Password is required
</div>
</ng-container>
</nb-form-field>

View File

@ -16,4 +16,17 @@
.show-grid{
margin-bottom: 2rem;
}
.error-message-container {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.error-message {
color: #7c0e0e;
}
.error-message.small {
font-size: 12px;
}

View File

@ -12,6 +12,7 @@ export class CustomerFormComponent implements OnInit {
data:any =[];
userForm: FormGroup | any; formData:any =[]
heading:any =[];
action: any;
constructor(private dialogRef: NbDialogRef<CustomerFormComponent> ,public _api:PageapiService,private dialogService: NbDialogService) {
@ -20,6 +21,8 @@ export class CustomerFormComponent implements OnInit {
ngOnInit() {
console.log('dialogRef', this.dialogRef.componentRef.instance);
let details:any = this.dialogRef.componentRef.instance
console.log('details',details)
this.action = details.action
this.heading = details.title
@ -64,6 +67,21 @@ export class CustomerFormComponent implements OnInit {
this.userForm.controls['password'].updateValueAndValidity();
}
this.userForm.patchValue(this.data)
// Add value change listener for password field
this.userForm.get('password').valueChanges.subscribe(value => {
const passwordControl = this.userForm.get('password');
if (value) {
passwordControl.setValidators([
Validators.required,
Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*_=+-]).{8,16}$')
]);
} else {
passwordControl.clearValidators();
}
passwordControl.updateValueAndValidity({ onlySelf: true, emitEvent: false });
});
}
cancel(){
@ -108,7 +126,10 @@ export class CustomerFormComponent implements OnInit {
this.formData.append('userName',tmp.userName)
this.formData.append('email', tmp.email);
if((tmp.password != "")){
// if((tmp.password != "")){
// this.formData.append('password', tmp.password);
// }
if (tmp.password) {
this.formData.append('password', tmp.password);
}

View File

@ -10,6 +10,7 @@
export const environment = {
apiEndpoint:'https://api.vnms.in/api/',
// apiEndpoint:'https://dev.venbait.in/vnms/api/',
// apiEndpoint:'http://localhost:8081/api/',
mailUrl:'',
production: false,