Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
Guest POR FAVOR ME AJUDEM!!&#3

Me Ajudem A Resolver Como...

Question

Guest POR FAVOR ME AJUDEM!!&#3

Ola pessoal!

Tenho um script de classificados com os campos nome, email, preço etc... e tambem tem o campo do anuncio "a area de texto" que e onde esta o problema.

O caso e que do jeito que esta o usuario não tem limite de caracteres e ele pode inserir um jornal inteiro.

Gostaria que "alguém" por favor me ajudasse a resolver isso.

Eu precisaria colocar um limite de por ex: maximo 150 caracteres, assim todos os anuncios ficariam padrão.

abaixo esta o arq que tem o codigo:

<!-- #include file="QCLib.asp" -->

<%

'*******************************************************************************

'* QuickClassifieds Copyright 2003 XCENT - www.xcent.com *

'* QuickClassifieds is a trademark of XCENT *

'* This notice may not be removed from this source code file *

'*******************************************************************************

sName = RequestValue("name")

sEmail = RequestValue("email")

sAddress = RequestValue("address")

sCity = RequestValue("city")

sState = RequestValue("state")

sZip = RequestValue("zip")

sCountry = RequestValue("country")

sTitle = RequestValue("title")

sContent = RequestValue("adcontent")

sLink = RequestValue("link")

sImage = RequestValue("imageurl")

fPrice = fVal(RequestValue("price"))

lCatID = fVal(RequestValue("catID"))

sCmd = RequestValue("CMD")

Set objErr = CreateObject("Scripting.Dictionary")

'set the formatting for the form to enter ads

sLabelCellOpen = "<tr><td width=""33%"" bgcolor=""" & gsPageBGColor & """>" & gsLabelOpen

sLabelCellClose = gsLabelClose & "</td>"

sInfoCellOpen = "<td width=""67%"" bgcolor=""" & gsPageBGColor & """>" & gsPlainTextOpen

sInfoCellClose = gsPlainTextClose & "</td></tr>"

DoPageHeader

OpenDBConn

TableHead GLS_PlaceAd

Select Case sCmd

Case "POST"

If CheckForm Then

PostAd

Else

ShowForm

End If

Case Else

ShowForm

End Select

TableFoot lCatID

CloseDBConn

DoPageFooter

set objErr = Nothing

Sub PostAd

vNow = Now

Set rsAd = Server.CreateObject("ADODB.RecordSet")

rsAd.Open "tblQCAds", gobjConnect, 1, 3, &H0002 'adOpenKeyset, adLockOptimistic, adCmdTable

rsAd.AddNew

rsAd("cadTopicID") = lCatID

rsAd("cadName") = sName

rsAd("cadEmail") = sEmail

rsAd("cadAddress") = sAddress

rsAd("cadCity") = sCity

rsAd("cadState") = sState

rsAd("cadZip") = sZip

rsAd("cadCountry") = sCountry

rsAd("cadTitle") = sTitle

rsAd("cadLink") = sLink

rsAd("cadDatePosted") = vNow

rsAd("cadImage") = sImage

rsAd("cadPrice") = fPrice

rsAd("cadContent") = sContent

rsAd.Update

lNewAdID = FVal(rsAd("cadID"))

rsAd.Close

set rsAd = Nothing

Response.Write gsPlainTextOpen & GLS_AdPostSuccess & "<BR>"

Response.Write "<A HREF=""QCViewDetail.asp?id=" & lNewAdID & """>" & GLS_AdPostView & "</A>" & gsPlainTextClose & "<BR>"

End Sub

Sub ShowForm

Response.Write "<CENTER>" & gsPlainTextOpen & GLS_ItemsMarked & gsPlainTextOpen & "</CENTER>"

Response.Write "<FORM METHOD = ""POST"" ACTION=""QCNewAdForm.asp"">"

Response.Write "<INPUT TYPE=""HIDDEN"" NAME=""cmd"" VALUE=""POST"">"

Response.Write "<TABLE border=""0"" cellspacing=""0"" width=""100%"" align=""CENTER"">"

Response.Write "<tr><td colspan=""2"" bgcolor=""" & gsPageBGColor & """>" & gsSubHeadOpen & GLS_YourInfo & gsSubHeadClose & "</td></tr>"

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("NAME"), True, objErr.Item("NAME"),GLS_YourName ) & gsReqSymbol & sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""name"" size=""27"" value=""" & sName & """ maxlength=""65"">" & sInfoCellClose

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("EMAIL"), True, objErr.Item("EMAIL"),GLS_EmailAddress )

ShowRequired(gbReqEmail)

Response.Write sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""email"" size=""27"" value=""" & sEmail & """ maxlength=""80"">" & sInfoCellClose

If gbShowStreet Then

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("STREET"), True, objErr.Item("STREET"),GLS_StreetAddress )

ShowRequired(gbReqStreet)

Response.Write sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""address"" size=""27"" value=""" & sAddress & """ maxlength=""65"">" & sInfoCellClose

End If

If gbShowCity Then

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("CITY"), True, objErr.Item("CITY"),GLS_City )

ShowRequired(gbReqCity)

Response.Write sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""city"" size=""27"" value=""" & sCity & """ maxlength=""50"">" & sInfoCellClose

End If

If gbShowState Then

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("STATE"), True, objErr.Item("STATE"),GLS_State )

ShowRequired(gbReqState)

Response.Write sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""state"" size=""3"" value=""" & sState & """ maxlength=""20"">" & sInfoCellClose

End If

If gbShowZipCode Then

Response.Write sLabelCellOpen & GLS_ZipCode & sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""zip"" size=""11"" value=""" & sZip & """>" & sInfoCellClose

End If

If gbShowCountry Then

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("COUNTRY"), True, objErr.Item("COUNTRY"),GLS_Country )

ShowRequired(gbReqCountry)

Response.Write sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""country"" size=""27"" value=""" & sCountry & """ maxlength=""50"">" & sInfoCellClose

End If

Response.Write "<tr><td colspan=""2"" bgcolor=""" & gsPageBGColor & """><P>&nbsp</P></td></tr>"

Response.Write "<tr><td colspan=""2"" bgcolor=""" & gsTableColor & """>" & gsSubHeadOpen & GLS_AdInformation & gsSubHeadClose & "</td></tr>"

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("CATEGORY"), True, objErr.Item("CATEGORY"),GLS_AddItemCat ) & gsReqSymbol & sLabelCellClose

Response.Write sInfoCellOpen

Response.Write "<SELECT NAME=""catID"">"

GetCategories

Response.Write "</SELECT>"

Response.Write sInfoCellClose

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("TITLE"), True, objErr.Item("TITLE"),GLS_AdTitle ) & gsReqSymbol & sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""title"" size=""27"" value=""" & sTitle & """ maxlength=""50"">" & sInfoCellClose

If gbShowPrice Then

Response.Write sLabelCellOpen & OutMatch(objErr.Exists("PRICE"), True, objErr.Item("PRICE"),GLS_AdPrice )

ShowRequired(gbReqPrice)

Response.Write sLabelCellClose

Response.Write sInfoCellOpen & gsMoneySymbol & "<input type=""text"" name=""price"" size=""10"" value=""" & OutMatch(fPrice,0, "", fPrice) & """>" & sInfoCellClose

End If

DEVE ESTAR POR AQUI

Response.Write "<tr><td width=""180"" bgcolor=""" & gsPageBGColor & """ valign=""top"">" & gsLabelOpen & OutMatch(objErr.Exists("CONTENT"), True, objErr.Item("CONTENT"),GLS_AdContent ) & gsReqSymbol & sLabelCellClose

Response.Write sInfoCellOpen & "<textarea rows=""9"" name=""adcontent"" cols=""39"">" & sContent & "</textarea>" & sInfoCellClose

Response.Write "<tr><td colspan=""2"" align=""CENTER""><FONT face=""" & gsFont & """ color=""#FF0000"" size=""2""><B>" & GLS_IncludeHTTP & "</B></FONT></td></tr>"

Response.Write sLabelCellOpen & GLS_AdLink & GLS_Optional & sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""link"" size=""27"" value=""" & sLink & """ maxlength=""100"">" & sInfoCellClose

Response.Write sLabelCellOpen & GLS_ImageURL & GLS_Optional & sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""text"" name=""imageurl"" size=""27"" value=""" & sImage & """ maxlength=""255"">" & sInfoCellClose

Response.Write sLabelCellOpen & "&nbsp;" & sLabelCellClose

Response.Write sInfoCellOpen & "<input type=""submit"" value=""" & GLS_Submit & """ name=""B1"">"

Response.Write "&nbsp;<input type=""reset"" value=""" & GLS_Reset & """ name=""B2"">" & sInfoCellClose

Response.Write "</table></FORM>"

End Sub

sub ShowRequired (bParam)

If bParam then

Response.write gsReqSymbol

End if

end sub

Sub GetCategories

sSQL = ""

sSQL = sSQL & "SELECT catID, catName FROM tblQCCategories ORDER BY catName"

Set rsCats = GobjConnect.Execute(sSQL)

If rsCats.EOF Then

Response.Write "<OPTION VALUE=""0"">" & GLS_NoCategory & "</OPTION>"

Else

Do While NOT rsCats.EOF

Response.Write "<OPTION VALUE=""" & rsCats("catID") & """"

If lCatID=FVal(rsCats("catID")) Then Response.Write " SELECTED "

Response.Write ">" & rsCats("catName") & "</OPTION>"

rsCats.MoveNext

Loop

End If

rsCats.Close

Set rsCats = Nothing

End Sub

Function CheckForm

objErr.RemoveAll

If Len(Trim(sName)) = 0 Then

objErr.Add "NAME", gsErrorTextOpen & GLS_InvalNameFld & gsErrorTextClose

End If

If Len(Trim(sEmail)) = 0 and gbReqEmail Then

objErr.Add "EMAIL", gsErrorTextOpen & GLS_InvalEMailFld & gsErrorTextClose

End If

If Len(Trim(sStreet)) = 0 and gbReqStreet and gbShowStreet Then

objErr.Add "STREET", gsErrorTextOpen & GLS_InvalStreetFld & gsErrorTextClose

End If

If Len(Trim(sCity)) = 0 and gbReqCity and gbShowCity Then

objErr.Add "CITY", gsErrorTextOpen & GLS_InvalCityFld & gsErrorTextClose

End If

If Len(Trim(sState)) = 0 and gbReqState AND gbShowState Then

objErr.Add "STATE", gsErrorTextOpen & GLS_InvalStateFld & gsErrorTextClose

End If

If Len(Trim(sCountry)) = 0 and gbReqCountry AND gbShowCountry Then

objErr.Add "COUNTRY", gsErrorTextOpen & GLS_InValCountryFld & gsErrorTextClose

End If

If Len(Trim(sTitle)) = 0 Then

objErr.Add "TITLE", gsErrorTextOpen & GLS_InValTitleFld & gsErrorTextClose

End If

If fPrice = 0 and gbReqPrice AND gbShowPrice then

objErr.Add "PRICE", gsErrorTextOpen & GLS_InValPriceFld & gsErrorTextClose

End if

If Len(Trim(sContent)) = 0 Then

objErr.Add "CONTENT", gsErrorTextOpen & GLS_InValContentFld & gsErrorTextClose

End If

If lCatID = 0 Then

objErr.Add "CATEGORY", gsErrorTextOpen & GLS_InvalCategory & gsErrorTextClose

End If

If objErr.Count > 0 Then

CheckForm = False

Else

CheckForm = True

End If

End Function

%>

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
Guest - Marcio -

limita ele no campo do DB seja ele access ou outro.

tipo assim coloca no valor do campo como limite os 150 caracteres.

espero ter ajudado.

Share this post


Link to post
Share on other sites
  • 0

Em javascript existe funções para limitar a digitação no formulario (textarea). Na tela de resgate das variaveis, você pode confirmar se está dentro do padrão de 150 caracteres, usando a função Len():

textarea = request.form("textarea")
if Len(textarea) >100 then
response.write "tem mais de 150 caracteres"
else

'continua rotina

end if

ps.: Marcio, porque você não se registra no forum?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

Cloud Computing


  • Forum Statistics

    • Total Topics
      148505
    • Total Posts
      644177
×
×
  • Create New...