0

Hello, someone know what's the error of my code? The Target of my code is show an alert that contains the contento of the input.

(Description is in spanish below of this) // I create a variable that takes the content entered un the input (html <input type="text" id="filling">) the variable doesn't stores input's valud :( : var age = document.getElementById("filling") // This function transforms the content of the input into an alert, and if it includes a letters, the system show an alert that says "Letters are not allowed": function show(age){ alert("Your age is" + age) if (age.includes("a"-"z")){ alert("Letters are not allowed") } ; } ; En español: // Creo una variable que toma el contenido ingresado en la entrada (html <input type="text" id="filling">): var edad = document.getElementById("relleno") // Esta función transforma el contenido de la entrada en una alerta, y si incluye letras, el sistema muestra una alerta que dice "No se permiten letras": función mostrar(edad){ alert ("Tu edad es" + edad) if (edad.includes("a"-"z")){ alert("No se permiten letras") } ; } ;

12th Jan 2023, 8:34 PM
Ceb ra
Ceb ra - avatar
3 odpowiedzi
+ 5
The problem with your code is that the includes() method does not accept a range of characters as an argument. You should use a regular expression instead, like this: if (age.match(/[a-z]/i)) { alert("Letters are not allowed"); }
12th Jan 2023, 8:48 PM
Reza Mardani
Reza Mardani - avatar
0
What app are you on cause I don't know this
13th Jan 2023, 5:13 PM
Osmany Baluta
Osmany Baluta - avatar
13th Jan 2023, 5:15 PM
Ceb ra
Ceb ra - avatar