Check. asp
CopyCode The Code is as follows: <%
''''''''''''''''''''''''''''''''''''
Function replacetext (fstring, patrn, replstr)
Set RegEx = new Regexp 'to create a regular expression.
RegEx. pattern = patrn 'setting mode.
RegEx. ignorecase = true' is used to set Case sensitivity.
RegEx. Global = true' to set global availability.
Replacetext = RegEx. Replace ("" & fstring & "", "" & replstr & "") 'to replace.
Set RegEx = nothing
End Function
''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''
Function htmlencode (fstring)
Fstring = trim (fstring)
Fstring = Replace (fstring, CHR (9 ),"")
Fstring = Replace (fstring, CHR (13 ),"")
Fstring = Replace (fstring, CHR (22 ),"")
Fstring = Replace (fstring, CHR (38), "&") '&"
Fstring = Replace (fstring, CHR (32), "") '""
Fstring = Replace (fstring, CHR (34), "") '"
Fstring = Replace (fstring, CHR (37), "%") '"%"
Fstring = Replace (fstring, CHR (39), "'") '''"
Fstring = Replace (fstring, CHR (42), "*") '"*"
Fstring = Replace (fstring, CHR (43), "+") '"+"
Fstring = Replace (fstring, CHR (44), ",") '","
Fstring = Replace (fstring, CHR (45) & CHR (45), "--") '"--"
Fstring = Replace (fstring, CHR (92), "\") '"\"
'Fstring = Replace (fstring, CHR (95), "_") '_"
Fstring = Replace (fstring, CHR (40), "(") '"("
Fstring = Replace (fstring, CHR (41), ")")"
Fstring = Replace (fstring, CHR (60), "<") '"<"
Fstring = Replace (fstring, CHR (62), ">") '">"
Fstring = Replace (fstring, CHR (123), "{") '"{"
Fstring = Replace (fstring, CHR (125), "}") '}"
Fstring = Replace (fstring, CHR (59), ";") ';"
Fstring = Replace (fstring, CHR (10), "<br> ")
Fstring = replacetext (fstring, "([]) ([a-z0-9] *);", "$1 $2 ;")
Fstring = replacetext (fstring, "(Fuck | shit)", string (LEN ("& $1 &"),"*"))
If issqldatabase = 0 then' filter katakana (Japanese character) [\ u30a0-\ u30ff] By yuzi
Fstring = escape (fstring)
Fstring = replacetext (fstring, "% u30 ([A-F] [0-f])", "$1 ;")
Fstring = Unescape (fstring)
End if
Htmlencode = fstring
End Function
''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''
Function requestint (fstring)
Requestint = request (fstring)
If isnumeric (requestint) then
Requestint = int (requestint)
Else
Requestint = 0
End if
End Function
''''''''''''''''''''''''''''''''''''
Username = htmlencode (Unescape (request. querystring ("username ")))
Usernamelength = requestint ("usernamelength ")
If Len (username) <> usernamelength then
Response. Write "invalid user name! "
Else
Response. write "the user name is valid! "
End if
%>
The htmlencode function is a required step to convert a user name to a valid character.
The requestint function determines whether the user name contains spaces based on the number of valid characters entered.
Call method: Check. asp? Username = username & usernamelength = username Length
Check. asp is generally used for Ajax judgment.