Quote:
quote:Originally posted by nikosdra
Hello all
Does anybody know how can I check if my users have used Latin characters in the submitted form, or else give them a message that they have to fill in the form with Latin characters only?
Thanks in advance
Nikos
|
Well I don't know any ASP check specifically geared towards checking only latin characters. You could loop through the characters from the text input and validate that they're all within the range you want.
Here's an example that checks for A-Z,a-z,0-9 and spaces:
Code:
dim i
dim badChar
dim stringToCheck
dim ch
stringToCheck=Request.Form("textinput") ' where textinput is your form field name
badChar=false
i=1
while i<=len(stringToCheck) and not(badChar)
ch=lcase(mid(stringToCheck,i,1))
if not((ch >= "a" and ch <= "z") or (ch >= "0" and ch <= "9") or (ch=" ")) then
badChar=true
end if
i=i+1
wend
if badChar then
' Report an error
end if
If you wanted to check for additional characters, simply add an additional
or clause for those characters to the character check.
This could also probably be done more efficiently with regular expressions but I don't have the time to look it up right now.
Bruce Luckcuck
Director, Applications & Support Services
Wiley Publishing, Inc.