IsAlphaNumeric Function :
Allows only white space, letters, numbers, and underscore characters to pass as valid input.
Description:
The IsAlphaNumeric function checks a string and allows only white space, letters of the alphabet, numbers, or underscore characters to pass as valid input.
Syntax:
boolean = IsAlphaNumeric(string)
Example:
<%
'--- IsAlphaNumeric returns True response.write IsAlphaNumeric("This Thing") response.write IsAlphaNumeric("This_Thing 155088_45515") response.write IsAlphaNumeric("Some_Other Thing_25") response.write IsAlphaNumeric(17968)
'--- IsAlphaNumeric returns False response.write IsAlphaNumeric("(37.8)") response.write IsAlphaNumeric("37.8A[") response.write IsAlphaNumeric("ABSD= acscrrrw!") response.write IsAlphaNumeric("11200-5432")
%>
ASP Source Code:
<%
Private Function IsAlphaNumeric(byVal string) dim regExp, match, i, spec For i = 1 to Len( string ) spec = Mid(string, i, 1) Set regExp = New RegExp regExp.Global = True regExp.IgnoreCase = True regExp.Pattern = "[A-Z]|[a-z]|\s|[_]|[0-9]|[.]" set match = regExp.Execute(spec) If match.count = 0 then IsAlphaNumeric = False Exit Function End If Set regExp = Nothing Next IsAlphaNumeric = True End Function
%>
|