File tree 3 files changed +14
-2
lines changed
3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,4 @@ function f_blur() {
8
8
document . getElementById ( 'nombre' ) . style . background = 'red' ;
9
9
alert ( 'Debe De Introducir Los Datos' )
10
10
}
11
- }
11
+ }
Original file line number Diff line number Diff line change 7
7
< script src ="https://cdn.jsdelivr.net/npm/sweetalert2@11 "> </ script >
8
8
</ head >
9
9
< body >
10
+ <!-- Ver Esto "onblur="blur()"" -->
10
11
< p > < textarea id ="texto " rows ="5 " cols ="22 " maxlength ="140 " onfocus ="vaciar(this) "> </ textarea > </ p >
11
12
< p > Caracteres Permitidos:
12
13
< span id ="cantidad "> 20</ scan >
Original file line number Diff line number Diff line change 1
1
document . getElementById ( 'texto' ) . addEventListener ( 'keyup' , caracteres ) ;
2
2
3
+
3
4
function caracteres ( ) {
4
5
const MAX_CARACTERES = 20 ;
5
6
let texto = document . getElementById ( 'texto' ) . value ;
7
+ document . getElementById ( 'texto' ) . style . background = '' ;
6
8
let cant = texto . length ;
7
9
let disponible = MAX_CARACTERES - cant ;
8
10
9
11
document . getElementById ( 'cantidad' ) . textContent = disponible ;
10
12
if ( disponible <= 0 ) {
11
13
swal . fire ( 'Caracteres agotados' ) ;
14
+ document . getElementById ( 'texto' ) . style . background = 'red' ;
12
15
document . getElementById ( 'texto' ) . value = "" ;
13
16
document . getElementById ( 'caracteres' ) . textContent = 20 ;
17
+
14
18
}
15
- }
19
+ }
20
+
21
+
22
+ // function blur() {
23
+ // if (document.getElementById('texto').value == '') {
24
+
25
+ // }
26
+ // }
You can’t perform that action at this time.
0 commit comments