-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodificar_mi_password.ejs
114 lines (85 loc) · 3.55 KB
/
modificar_mi_password.ejs
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
<!DOCTYPE html>
<html lang="es">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.2.0/css/bootstrap.min.css" rel="stylesheet">
<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">
<%- include ('header', {tituloweb: '¡Oh my dog! | Modificar cliente'}); %>
</head>
<body id="body">
<div class="container h-100" style="margin-top: 20px;">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-lg-12 col-xl-10">
<div class="card text-black" style="border-radius: 25px;">
<div class="card-body p-md-4">
<div class="row justify-content-center">
<form method="POST">
<p class="text-center h1 fw-bold mb-4 mx-1 mx-md-4 mt-3"><i class="bi bi-person-lock"></i> Modificar su contraseña</p>
<div class="mb-3">
<div class="mb-3">
<label for="pass">Contraseña actual*:</label>
<input class="form-control form-control-user" name="pass" value="" type="password" id="password" placeholder="" required="">
</div>
<div class="mb-3">
<label for="pass">Contraseña nueva*:</label>
<input class="form-control form-control-user" name="pass2" value="" type="password" id="password2" placeholder="" required="">
</div>
<div class="mb-3">
<label for="pass">Confirmacion de contraseña nueva*:</label>
<input class="form-control form-control-user" name="pass3" value="" type="password" id="password3" placeholder="" required="">
</div>
</div>
</div>
<div class="row mb-1">
<div class="error-container" style="height: 30px; margin-bottom: 10px;">
<p id="passwordErrorMsg" class="text-danger" style="display: none;"></p>
<p id="coincidirMsg" class="text-danger" style="display: none;"></p>
</div>
</div>
<button class="btn btn-primary d-block btn-user w-100" id="submitBtn" type="submit">Actualizar</button>
<hr>
</form>
<div class="text-center mb-2" style="font-size: smaller;">Los campos con (*) son obligatorios</div>
<div class="text-center"><a class="small" href="/modificar_mi_perfil">Volver</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
<%- include ('sweet-alert') %>
<div id="usuario" usuario="<%- JSON.stringify(usuario) %>"></div>
<!-- SCRIPT -->
<script>
const password = document.getElementById("password2");
const confirmarPassword = document.getElementById("password3");
const submitBtn = document.getElementById("submitBtn");
const passwordErrorMsg = document.getElementById("passwordErrorMsg");
function displayErrorMsg(msg) {
passwordErrorMsg.style.display = "block";
passwordErrorMsg.textContent = msg;
submitBtn.disabled = true;
}
function hideErrorMsg() {
passwordErrorMsg.style.display = "none";
passwordErrorMsg.textContent = "";
submitBtn.disabled = false;
}
function validatePassword() {
const passwordValue = password.value;
const confirmarPasswordValue = confirmarPassword.value;
if (passwordValue.length < 8) {
displayErrorMsg("La contraseña debe tener 8 caracteres o más");
} else if (passwordValue !== confirmarPasswordValue) {
displayErrorMsg("Las contraseñas deben coincidir");
} else {
hideErrorMsg();
}
}
password.addEventListener("input", validatePassword);
confirmarPassword.addEventListener("input", validatePassword);
</script>
</body>
</html>