Ciao a tutti, torno a chiedere aiuto, devo implementare in un form due script uno che controlla che parole inserite rispettino il buon senso e l'educazione, e l'altro che limiti il numero di caratteri per parola da inserire nel database, ho trovato qualcosa,(già inseriti) ma il problema è che quando scrivo la prima parola, e poi una lunga, arrivando al limite di caratteri concesso dallo script, nella visuazione nel marquee, la seconda parola va a capo!! non so proprio come risolvere il problema, vi posto il codice magari riuscite ad aiutarmi, grazie mille!
questa è la pagina el modulo:
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Invia Messaggio</title>
<script type="text/javascript" src="js/mootools-for-textarea.js"> </script>
<script type="text/javascript" src="js/UvumiTextarea-compressed.js"> </script>
<link rel="stylesheet" type="text/css" media="screen" href="css/uvumi-textarea.css" />
<style type="text/css">
body,html{
background-color:#ffffff;
margin:0;
padding:0;
font-family:Trebuchet MS, Helvetica, sans-serif;
}
#main{
margin:5% 20%;
height:250px;
width:460px;
position:relative;
overflow:auto;
color:#aaa;
padding:20px;
border:1px solid #888;
background-color:;
#
}
</style>
<script type="text/javascript">
new UvumiTextarea({
selector:'textarea.withCounter',
maxChar:60
});
new UvumiTextarea({
selector:'textarea.withoutCounter',
maxChar:60
});
</script>
<script type="text/javascript">
badWords=[
"casa",
"mela",
"pera",
"viagra",
]
function test(obj){
//obj=document.getElementById("story2")
currentText=obj.value
for(var i=0;i<badWords.length;i++){
re=new RegExp(badWords[i],"gi")
if(re.test(currentText)){
temp=""
for(var j=0;j<badWords[i].length;j++){temp+="*"}
currentText=currentText.replace(re,temp)
obj.value=currentText
}
}
}
</script>
<font color="#5533cc" size="4" style="font-style:italic; font-family:Arial Rounded MT Bold; word-spacing: 3px; text-align:left"
><%
function indirizzo()
indirizzo = "Il tuo indirizzo I.P. è : " & Request.ServerVariables("REMOTE_ADDR")
end function
response.write indirizzo()
%></font>
</head>
<div id="main">
<form method="POST" action="inserisci.asp" style="width: 400px">
Nome<input type="text"name="nome" size="20">
</p>
Messaggio
<textarea id="story2" class="withCounter" onkeyup="test(this)" onchange="test(this)" align="left"
input type="text"name="messaggi" size="20" style="width: 270px; height:73px;"></textarea>
<input type="submit" value="Invia"name="x" style="width: 57px; height: 24px;"
onclick="Controllo()"> </p>
</form>
<script type="text/javascript">
function Controllo()
{
var testo = document.modulo.testo.value;
if (testo == "" || testo == "undefined" || testo.charAt(0) == " ")
{
alert("Inserisci un testo");
}
else
{
// VARIABILI PER:
// IL CICLO
// PER LA GESTIONE DEGLI ERRORI
// PER IL MASSIMO NUMERO DI CARATTERI CONSECUTIVI CONSENTITI
var i = 0;
var errore = 0;
var max_lunghezza = 5;
// DIVIDO IL VALORE DEL CAMPO DEL FORM IN UN ARRAY DI STRINGA
//PER DIVIDERE USO IL CARATTERE SPAZIO VUOTO
var s = testo.split(" ");
// ESEGUO UN CICLO PER CONTROLLARE TUTTI I VETTORI DELL'ARRAY CHE HO CREATO
while (i<s.length && errore == 0)
{
// VALORIZZO LA VARIABILE errore A SECONDA DELLA LUNGHEZZA DEI VETTORI
s[i].length > max_lunghezza ? errore = 1 : errore = 0;
// SE errore == 1 VUOL DIRE CHE C'E' UNA PAROLA TROPPO LUNGA
if (errore == 1)
{
alert("Hai inserito una parola troppo lunga");
}
i++; // INCREMENTO IL CONTATORE DEL CICLO
}
// SE NEL CICLO NON TROVO VETTORI TROPPO LUNGHI L'ESITO E' POSITIVO
if (errore == 0)
{
alert("OK");
}
}
}
</script>
<body>
</div>
</body>
</html>
Questa è la pagina da dove vengono inseriti i dati in access
<%
dim a,b
a = request.form("nome")
b = request.form("messaggi")
Set Conn=Server.CreateObject("ADODB.Connection")
strConn="driver={Microsoft Access Driver (*.mdb)}; "
strConn= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("/mdb-database/messaggi.mdb")&";"
Conn.Open strConn
sql = "SELECT * FROM Messaggix"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn ,3,3
'scrittura nuovo record
rs.addnew
rs(1) = a
rs(2) = b
rs.update
' Chiusura del database
rs.Close
set rs = Nothing
conn.Close
set conn = Nothing
response.write "inserimento avvenuto"
%>
<%
dim stringa, arr_str, i, record
stringa = request("messaggi")
arr_str = split(stringa, " ")
i = 0
for i = 0 to UBound(arr_str)
if Len(arr_str(i)) > 10 then
record = record & Left(arr_str(i), 10) & " "
else
record = record & arr_str(i) & " "
end if
next
%>
questa è la pagina che legge dal database.
<%
Dim sc, cn, rs, cont
sc = ""
sc = sc & "driver={Microsoft Access Driver (*.mdb)};dbq="
sc = sc & Server.MapPath("/mdb-database/messaggi.mdb")
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
cn.Open sc
%>
<html>
<head>
<title></title>
</head>
<body>
<marquee behavior="scroll" direction="left" scrollamount="2" align="middle" behavior="scroll" direction="left" scrolldelay="5">
<table border="0"><tr>
<%
cont = 0
rs.Open "SELECT top 10 * FROM messaggix ORDER BY id desc", cn, 1
While rs.EOF = False
If cont = 10 Then
cont = 0
Response.Write "</tr><tr>"
End If
%>
<td> <font color="#1e90ff" size="2" style="font-style:; font-family:Verdana; word-spacing: 10px; text-align:right"
><%=rs("nome")%></font><font color="#6699FF" size="2" style="font-style:; font-family:Verdana; ">~</font><font color="#87cefa" size="2" style="font-style:; font-family:Verdana; word-spacing: 10px; text-align:right"
><%=rs("messaggi")%>
[img]/images/notona.gif[/img]
</td>
<%
rs.MoveNext
cont = cont + 1
Wend
rs.Close
%>
</tr></table></marquee>
</p>
</p>
inserisci mess</p>
</body>
</html>
<%
Set rs = Nothing
cn.Close
Set cn = Nothing
%>
GRAZIE![]()
![]()
![]()
Grazie

Rispondi quotando
Ciao, ho notato che succede che va acapo dopo uno spazio, come se non interpreta gli spazi!! 