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.