Current location: Hot Scripts Forums » Programming Languages » ASP » text area validation


text area validation

Reply
  #1 (permalink)  
Old 05-15-04, 10:00 AM
adit adit is offline
New Member
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile text area validation

Hi all...

I am a beginner in ASP, i am using javascript for my website.., I would like to know how to validate my text area..., I have a form with text area and will send the data to access database. and I do not want the user write certain character like " ' " within my text area,

could you guys help how to validate my text area??..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-24-04, 09:45 PM
Mikeirv Mikeirv is offline
Newbie Coder
 
Join Date: May 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by adit
Hi all...

I am a beginner in ASP, i am using javascript for my website.., I would like to know how to validate my text area..., I have a form with text area and will send the data to access database. and I do not want the user write certain character like " ' " within my text area,

could you guys help how to validate my text area??..
Hi, I am guessing that you don't want them to write a " ' " in your text area because it messes up your sql statement when putting it in the database.

If this is the case do a replace in your sql statement. (On lastname here)

sql = "INSERT into tblnames (firstname, Lastname) VALUES ('" & firstname & "', '" & replace(Lastname, "'", "''") & "')"

If that is not the case and you just want to check to see if they used certain characters and stop it if they did then you can check for that character and kick them back.

MyText = Request.Form("Textarea")

if instr(1, MyText, "'") <> 0 then
Response.redirect "form.asp"
elseif instr(1, MyText, "Y") <> 0 then
Response.redirect "form.asp"
end if

insert...


This way, if they typed something you don;t want, they get put back at the form.

Hope it helped
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-26-04, 02:41 AM
Thunderbunny Thunderbunny is offline
New Member
 
Join Date: Mar 2004
Location: Oregon
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by adit
Hi all...

I am a beginner in ASP, i am using javascript for my website.., I would like to know how to validate my text area..., I have a form with text area and will send the data to access database. and I do not want the user write certain character like " ' " within my text area,

could you guys help how to validate my text area??..
As an alternate to the previous reply, you can also use the InStr function to catch offending chars and just excise them prior to sending to your database...

Your code would contain something like

Function stripBadChars(strTextFromForm)
Dim idx, sChar, tmpString, strBadChars

strBadChars="'/|\()*&^%$#@~`" & Chr(34)

for idx=1 to Len(strTextFromForm)
sChar = Mid(strTextFromForm,idx,1)
If (InStr(1,strBadChars, sChar)) Then 'We found a bad char
'do nothing and throw away the character
Else
tmpString = tmpString & sChar
End If
Next

stripBadChars = tmpString
End Function

Dim goodString

goodString = stripBadChars(request.Form(myTextArea))


- Just a thought. Happy coding.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Query problem Wraith PHP 5 03-06-04 06:16 PM
text area and hyperlinking aparna PHP 3 01-02-04 02:37 AM
text area and hyperlinking aparna PHP 0 12-30-03 10:47 AM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 08:19 PM
displaying all duplicate records in my table. dsumpter PHP 6 09-02-03 11:54 AM


All times are GMT -5. The time now is 08:54 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.