just another validation for reading form values. I see a lot of questions beiong asked regarding these two methods in VBscript. Checking for characters and getting rid of spaces. The script is fairly easy to chagne to only perform one or the either or leave as is for both. I gathered this code from others and myself to create the shortest easiest one I could come up with. Happy Coding!
<HTML> <HEAD><TITLE>Simple Validation</TITLE> <SCRIPT LANGUAGE="VBScript"> <!-- Sub Validate() Dim Illchars, charcnt, banned, valid, inputvalue ' add characters to the Illchars var within the quotes Illchars = "'^\/()#~<>|`ΒΌ:;!@$*+=%" valid = True inputvalue = form1.Text1.value
'check for any value if inputvalue = "" or inputvalue = null then alert "please make a entry for submission", vbOK exit sub end if
' trim the spaces left and right inputvalue = Trim(Replace(inputvalue, " ", ""))
For charcnt = 1 to Len(Illchars) banned = Mid(Illchars, charcnt, 1) If InStr(inputvalue, banned) > 0 Then valid = False Exit For End If Next
If Not valid Then Str = "" MyVar = MsgBox ("You have entered characters not valid. Please try again!")
Exit Sub End If
Dim TheForm, MyVar TheForm=form1.Text1.value 'replace spaces... Do While InStr(1, TheForm, " ") TheForm = Replace(TheForm, " ", "") Loop MyVar = MsgBox ("Here it is without spaces, as long as you made it this far" & TheForm) End Sub