ASP Ajax registration Verification to prevent user name input space _ Application Tips

Source: Internet
Author: User
Tags chr
Check.asp
Copy Code code as follows:

<%
''''''''''''''''''''''''''''''''''''
Function ReplaceText (FSTRING,PATRN,REPLSTR)
Set regEx = New RegExp ' establishes a regular expression.
Regex.pattern = Patrn ' Set mode.
Regex.ignorecase = True ' Sets whether case sensitive.
Regex.global = True ' Sets global availability.
ReplaceText = Regex.Replace ("&fString&" "," "&replStr&") ' 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), "&") ' & '
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) &AMP;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), "<") ' < '
Fstring=replace (FSTRING,CHR), ">") ' > '
Fstring=replace (FSTRING,CHR (123), "{") ' "{"
Fstring=replace (FSTRING,CHR (125), "}") ' "}"
Fstring=replace (FSTRING,CHR (59), ";") '; '
Fstring=replace (FSTRING,CHR), "<br>"
Fstring=replacetext (Fstring, "([&#])" ([a-z0-9]*); "," $1$2; ")
Fstring=replacetext (Fstring, "(Fuck|shit)", String (Len ("&$1&"), "*")
If Issqldatabase=0 then ' filter Katakana (Japanese characters) [\u30a0-\u30ff] by Yuzi
Fstring=escape (fstring)
Fstring=replacetext (Fstring, "%u30 ([a-f][0-f])", "0$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 "User name is illegal! "
Else
Response.Write "User name is legal! "
End If
%>

The HTMLEncode function is the necessary step to convert a user name to a legitimate character.
The Requestint function mainly determines whether a user name contains spaces based on the number of valid characters entered.
Call method: Check.asp? Username= username &usernamelength= User name length
Check.asp is generally used for AJAX judgments
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.