-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
132 lines (128 loc) · 8.02 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Change Password</title>
<!-- font awesome cdn -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- bootstrap 5 cdn -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<!-- google font link -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;0,1000;1,400;1,500;1,700;1,1000&display=swap" rel="stylesheet">
<!-- vue js cdn -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<!-- sweet alert cdn -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="icon" href="./images/skillshare_logo.png">
</head>
<body>
<div class="container-fluid">
<div class="row px-4" id="newPassword">
<div class="col-md-6 offset-md-3">
<div class=" my-4 img-container w-100 d-flex justify-content-center "><img src="./images/skillshare_logo.png" class="img-fluid" alt=""></div>
<h3 class="text-center">Change Your Password</h3>
<p class="text-center mb-3">Enter a new password below to change your password.</p>
<form action="" @submit.prevent="changePassword">
<div class="input-gp mb-3">
<input required="" type="password" name="password" class="password-input" v-model="password" @input="validatePassword" :type="passwordFieldType">
<i class="fa-regular eye-icon" :class="{'fa-eye': passwordFieldType == 'password' , 'fa-eye-slash' : passwordFieldType == 'text'}" @click="togglePasswordVisibility"></i>
<label for="password" class="password-label">New password</label>
</div>
<div class="input-gp mb-3">
<input required="" type="password" name="password-confirmation" id="" class="password-input" v-model="password_confirmation" :type="confirmPasswordFieldType">
<i class="fa-regular eye-icon" :class="{'fa-eye': confirmPasswordFieldType == 'password' , 'fa-eye-slash' : confirmPasswordFieldType == 'text'}" @click="toggleConfirmPasswordVisibility"></i>
<label for="password-confirmation" class="password-label">Re-enter new password</label>
</div>
<div class="card p-3 validation-text">
<span>Your password must contain:</span>
<span class="d-flex align-items-center" :class="{'txt-success' : passwordLengthValid}"><i class="fa-solid me-2" :class="{'fa-check' : passwordLengthValid , 'fa-circle' : !passwordLengthValid}"></i>At least 8 characters</span>
<span class="d-flex align-items-center" :class="{'txt-success' : atLeast3}"><i class="fa-solid me-2" :class="{'fa-check' : atLeast3 , 'fa-circle' : !atLeast3}"></i>At least 3 of the following: </span>
<span class="ms-3 d-flex align-items-center" :class="{'txt-success' : passwordLowerValid}"><i class="fa-solid me-2" :class="{'fa-check' : passwordLowerValid , 'fa-circle' : !passwordLowerValid}"></i>Lower case letters</span>
<span class="ms-3 d-flex align-items-center" :class="{'txt-success' : passwordUpperValid}"><i class="fa-solid me-2" :class="{'fa-check' : passwordUpperValid , 'fa-circle' : !passwordUpperValid}"></i>Upper case letters(A-Z)</span>
<span class="ms-3 d-flex align-items-center" :class="{'txt-success' : passwordNumberValid}"><i class="fa-solid me-2" :class="{'fa-check' : passwordNumberValid , 'fa-circle' : !passwordNumberValid}"></i>Numbers (0-9)</span>
<span class="ms-3 d-flex align-items-center" :class="{'txt-success' : passwordSpecialValid}"><i class="fa-solid me-2" :class="{'fa-check' : passwordSpecialValid , 'fa-circle' : !passwordSpecialValid}"></i>Special characters (e.g. !@#$%^&*)</span>
</div>
<button type="submit" class=" mt-4 btn w-100 py-3 fw-bold" style="background-color: #06d6a0;">Reset password</button>
</form>
</div>
</div>
</div>
<!-- bootstrap js -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
<!-- vue js codes here -->
<script>
new Vue({
el : '#newPassword',
data : {
password : '',
password_confirmation : '',
passwordLengthValid : false,
passwordLowerValid : false,
passwordUpperValid : false,
passwordNumberValid : false,
passwordSpecialValid : false,
atLeast3 : false,
passwordFieldType : 'password',
confirmPasswordFieldType : 'password',
},
methods : {
//check validation from input
validatePassword() {
this.passwordLengthValid = this.password.length > 8 ? true : false;
this.passwordLowerValid = /[a-z]/.test(this.password)? true : false;
this.passwordUpperValid =/[A-Z]/.test(this.password)? true : false;
this.passwordNumberValid = /[0-9]/.test(this.password)? true : false;
this.passwordSpecialValid = /[!@#$%^&*]/.test(this.password)? true : false;
const trueCount = [
this.passwordLowerValid,
this.passwordUpperValid,
this.passwordNumberValid,
this.passwordSpecialValid
].filter(value => value).length;
this.atLeast3 = trueCount >= 3 ? true : false;
},
//when click submit button
changePassword() {
if(!(this.password == this.password_confirmation)) {
Swal.fire({
position: 'center',
icon: 'error',
text: 'Passwords not match',
showConfirmButton: true,
})
}else {
if(this.passwordLengthValid && this.atLeast3) {
Swal.fire({
position: 'center',
icon: 'success',
text: 'Password changed successfully',
showConfirmButton: true,
})
this.password = '';
this.password_confirmation = '';
}else {
Swal.fire({
position: 'center',
icon: 'info',
text: 'Please complete our validation rules',
showConfirmButton: true,
})
}
}
},
togglePasswordVisibility() {
this.passwordFieldType = this.passwordFieldType == 'password'? 'text' : 'password';
},
toggleConfirmPasswordVisibility() {
this.confirmPasswordFieldType = this.confirmPasswordFieldType == 'password'? 'text' : 'password';
}
}
})
</script>
</body>
</html>