我需要确保某人的密码符合特定条件才能继续创建其帐户。我想添加一个声明,检查'
,"
和,
。该应用程序在VBScript中。这就是我到目前为止所拥有的。我在网上找不到任何东西。
IsComplex = True
'Check Length
If Len(cPassword) < 8 Then
IsComplex = False
End If
'Check for lowercase letters
HasLowerCase = False
For x = 97 to 122
If Instr(4,cPassword,chr(x)) > 0 Then
HasLowerCase = True
End If
Next
If HasLowerCase = False Then
IsComplex = False
cForceChange = "E"
End If
'Check for uppercase letters
HasUpperCase = False
For x = 65 to 90
If Instr(1,cPassword,chr(x)) > 0 Then
HasUpperCase = True
End If
Next
If HasUpperCase = False Then
IsComplex = False
cForceChange = "E"
End If
'Check for numbers
HasNumber = False
For x = 48 to 57
If Instr(1,cPassword,chr(x)) > 0 Then
HasNumber = True
cForceChange = "E"
End If
Next
If HasNumber = False Then
IsComplex = False
cForceChange = "E"
End If
答案 0 :(得分:2)
你可以按字面意思检查它们:
If InStr(cPassword, "'") > 0 Then ' Single-quote found
If InStr(cPassword, """") > 0 Then ' Double-quote found (need to use TWO quotes)
If InStr(cPassword, ",") > 0 Then ' Comma found
唯一棘手的是双引号("
)。由于VBScript将此用于字符串文字,因此当您需要在字符串文字中引用它时,必须将其转义(通过使用其中两个)。