*Form validation: A-Z* I subscribe to allot of ASP mail lists, and one thing that came up was how to check if a string fetched from a form contained only alpha numeric characthers (A-Z, a-z and 0-9). I saw some solutions made in client side JavaScript, but I thought that it could just as well be done in VBScript server side. So I made a script for it, and put it in a function: <% FUNCTION TestString(SomeString) TempString = TRIM(SomeString) TempString_Length = Len(TempString) TempString_OK = true FOR TempString_Pos = 1 TO TempString_Length TempString_Char = Mid(TempString,TempString_Pos) TempString_Char_Ansi = Asc(TempString_Char) IF TempString_Char_Ansi > 47 AND TempString_Char_Ansi < 123 THEN IF TempString_Char_Ansi > 57 AND TempString_Char_Ansi < 65 THEN TempString_OK = False EXIT FOR END IF IF TempString_Char_Ansi > 90 AND TempString_Char_Ansi < 97 THEN TempString_OK = False EXIT FOR END IF ELSE TempString_OK = False EXIT FOR END IF NEXT TestString = TempString_OK END FUNCTION %> It uses the fact that any char has an ANSI value. So by checking the ANSI value of every char I can see if it alpha numeric or not. The ANSI codes is: A-Z is 65-90, 97-122 is a-Z and 48-57 is 0-9. To see all the ANSI values use this script:
<%FOR i=0 TO 255%> <%=i%>: <%=CHR(i)%>