Skip to content

Commit cd9e18b

Browse files
committed
conteo caracteres 2.0
1 parent 7f97d59 commit cd9e18b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Diff for: 15-formularios/8-onBlur/script.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ function f_blur() {
88
document.getElementById('nombre').style.background = 'red';
99
alert('Debe De Introducir Los Datos')
1010
}
11-
}
11+
}

Diff for: 19-conteoCaracteres/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
88
</head>
99
<body>
10+
<!-- Ver Esto "onblur="blur()"" -->
1011
<p><textarea id="texto" rows="5" cols="22" maxlength="140" onfocus="vaciar(this)"></textarea></p>
1112
<p>Caracteres Permitidos:
1213
<span id="cantidad">20</scan>

Diff for: 19-conteoCaracteres/script.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
document.getElementById('texto').addEventListener('keyup', caracteres);
22

3+
34
function caracteres() {
45
const MAX_CARACTERES = 20;
56
let texto = document.getElementById('texto').value;
7+
document.getElementById('texto').style.background = '';
68
let cant = texto.length;
79
let disponible = MAX_CARACTERES - cant;
810

911
document.getElementById('cantidad').textContent = disponible;
1012
if (disponible <= 0){
1113
swal.fire('Caracteres agotados');
14+
document.getElementById('texto').style.background = 'red';
1215
document.getElementById('texto').value = "";
1316
document.getElementById('caracteres').textContent = 20;
17+
1418
}
15-
}
19+
}
20+
21+
22+
// function blur() {
23+
// if (document.getElementById('texto').value == '') {
24+
25+
// }
26+
// }

0 commit comments

Comments
 (0)