Hello..
I have some code used for server-side form input validation.
This loops through each char in the string and checks to see if it's a valid character (based on ASCII values)
I would like to make this into a function or sub (whatever is best).
I imagine that there is a way to make the "invalid input checker" into a function. I'd love to be able to use this validation thing by doing something like:
FunctionName(uname)
Where FunctionName is the name of my function and UNAME is the variable that it is checking for validity.
I am learning about functions, but I cannot seem to figure out WHERE or WHAT to put in the argument list that follows the function name when it's used or called.
Example:
In the char validation code, the only place I refrence the variable to be evaluated is the line:
unamemText = uname
Question:
How do I make the above into a function and what do I put in the code or arglist to make it so I can simply do a FUNCTION(variable.to.be.validated) and the variable that I put in the arglist would be tested using my code.
(plz ignore the error message stuff. I'll take care of that once I learn how to make and use the function properly)
Plz let me know if I need to clarify, because I bet it's a simple question that I am making sound really really complicated.
-* D *-
I have some code used for server-side form input validation.
This loops through each char in the string and checks to see if it's a valid character (based on ASCII values)
Code:
DIM unamemText, unamemOKstr, unamemChr, unamemASCchr, unamemRet
DIM unamei
DIM unamemErrMsg, unamemBlankRow
unamemBlankRow = "<TR><TD> </TD></TR>"
unamemText = uname
unamemOKstr = "_.-@"
unamemret = True
FOR unamei = 1 TO Len(unamemText)
unamemChr = Mid(unamemText, unamei, 1)
unamemASCchr = ASC(unamemChr)
IF NOT ((unamemASCChr >=65 AND unamemASCChr <=90) _
OR (unamemASCchr >=97 AND unamemASCchr <=122) _
OR (unamemASCchr >=48 AND unamemASCChr <=57)) Then
IF Instr(1, unamemOKstr, unamemChr)= 0 Then
unamemRet= False
Exit For
END IF
END IF
NEXT
IF unamemRet = False Then
errExists = errExists + 1
errUname = "<B>Username</B> contains invalid characters.<BR>" & _
"Valid Characters are " & unamemOkstr & "<BR>"
END IF
I would like to make this into a function or sub (whatever is best).
I imagine that there is a way to make the "invalid input checker" into a function. I'd love to be able to use this validation thing by doing something like:
FunctionName(uname)
Where FunctionName is the name of my function and UNAME is the variable that it is checking for validity.
I am learning about functions, but I cannot seem to figure out WHERE or WHAT to put in the argument list that follows the function name when it's used or called.
Example:
In the char validation code, the only place I refrence the variable to be evaluated is the line:
unamemText = uname
Question:
How do I make the above into a function and what do I put in the code or arglist to make it so I can simply do a FUNCTION(variable.to.be.validated) and the variable that I put in the arglist would be tested using my code.
(plz ignore the error message stuff. I'll take care of that once I learn how to make and use the function properly)
Plz let me know if I need to clarify, because I bet it's a simple question that I am making sound really really complicated.
-* D *-