form validation error query

This commit is contained in:
Chneemann 2024-08-02 04:45:47 +02:00
parent e33b751be3
commit 355de791a0
4 changed files with 33 additions and 2 deletions

View file

@ -16,8 +16,10 @@
placeholder="Email Address" placeholder="Email Address"
autocomplete="email" autocomplete="email"
[(ngModel)]="authData.mail" [(ngModel)]="authData.mail"
disabled
required required
/> />
<div class="error-msg"></div>
<input <input
type="password" type="password"
id="password" id="password"
@ -26,8 +28,15 @@
placeholder="Enter a password" placeholder="Enter a password"
autocomplete="new-password" autocomplete="new-password"
[(ngModel)]="authData.password" [(ngModel)]="authData.password"
pattern="[^<>]*"
minlength="6"
required required
/> />
<div class="error-msg">
@if (authData.password.length < 6 && password.touched) {
<p>Password is too short, min 6 characters</p>
}
</div>
<input <input
type="password" type="password"
id="passwordConfirm" id="passwordConfirm"
@ -36,8 +45,16 @@
placeholder="Confirm password" placeholder="Confirm password"
autocomplete="new-password" autocomplete="new-password"
[(ngModel)]="authData.passwordConfirm" [(ngModel)]="authData.passwordConfirm"
pattern="[^<>]*"
minlength="6"
required required
/> />
<div class="error-msg">
@if (authData.password !== authData.passwordConfirm &&
passwordConfirm.touched) {
<p>The passwords do not match</p>
}
</div>
<app-btn-large <app-btn-large
[value]="'Get Started'" [value]="'Get Started'"
[disabled]=" [disabled]="

View file

@ -37,12 +37,25 @@ section {
} }
} }
.error-msg {
display: flex;
align-items: center;
justify-content: center;
height: 24px;
padding: 6px;
width: 120%;
p {
color: $red;
font-size: 12px !important;
font-weight: 400 !important;
}
}
.register-form { .register-form {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 32px;
input { input {
width: 90%; width: 90%;
padding: 12px 18px; padding: 12px 18px;

View file

@ -11,7 +11,7 @@ import { FormsModule, NgForm } from '@angular/forms';
}) })
export class RegisterComponent { export class RegisterComponent {
authData = { authData = {
mail: '', mail: 'test@test.de',
password: '', password: '',
passwordConfirm: '', passwordConfirm: '',
}; };

View file

@ -3,3 +3,4 @@ $white: #fff;
$black: #000; $black: #000;
$gray: #ababab; $gray: #ababab;
$blue: #2e3edf; $blue: #2e3edf;
$red: #ff0000;