Hello, good afternoon, I have this problem in javascript:
I have an advance in which this javascript tells you through a text box, how many characters and words you write and sends it on a screen, but I require this to be done with a menu, where the user types a message and have the following conditions:
If the message or string written in the text box is less than 10 characters and any word (s) printed on the screen is a short string.
If the message or string written in the text box is greater than 10 characters and less than 20 characters, any word (s) that print on the screen is medium string.
If the message or string written in the text box is greater than 20 characters and any word (s) printed on the screen is a long string.
But I do not know how to put these conditions with what I have, please help me, thank you.
<html>
<head>
<title>Caracteres</title>
<meta charset="utf-8">
<style type="text/css">
body {
background-color:#DBDFDB;
}
</style>
</head>
<body>
<font color="#030303" face="georgia" size="5">
<center>
<TABLE BORDER=3 width="1000" height="50">
<TR><TD>
<font face="georgia" size="30">
<MARQUEE SCROLLAMOUNT=10 BEHAVIOR="alternate"><b>Programa para calcular caracteres</b></MARQUEE>
</font>
</TD></TR>
</TABLE>
<p>Menu: </p>
<p>1 a 10 Es una cadena corta</p>
<p>10 a 20 Es una cadena media</p>
<p>Mayores a 20 Es una cadena larga</p>
<script type="text/javascript">
function wordCount() {
textoArea = document.getElementById("area").value;
numeroCaracteres = textoArea.length;
inicioBlanco = /^ /
finBlanco = / $/
variosBlancos = /[ ]+/g
textoArea = textoArea.replace(inicioBlanco,"");
textoArea = textoArea.replace(finBlanco,"");
textoArea = textoArea.replace(variosBlancos," ");
textoAreaDividido = textoArea.split(" ");
numeroPalabras = textoAreaDividido.length;
tC = (numeroCaracteres==1)?" carácter":" caracteres";
tP = (numeroPalabras==1)?" palabra":" palabras";
alert (numeroCaracteres + tC +"\n" + numeroPalabras + tP);
}
</script>
<FORM ID="formulario" ACTION="#">
<TEXTAREA ID="area" COLS=20 ROWS=10>
Texto dentro del área de texto </TEXTAREA><BR>
<INPUT TYPE="button" VALUE="Contar las palabras" onClick="wordCount();">
</FORM>
</center>
</font>
</body>
</html>