我需要确保某人的密码符合特定标准,然后他们才能继续创建帐户。我想添加一条语句检查 '
、"
和 ,
。该应用程序采用 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
最佳答案
您可以逐字检查它们:
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 将其用于字符串文字,因此当您需要在内部引用它时,必须对其进行转义(通过使用其中两个)字符串文字。
关于forms - 检测字符串中的引号 ("), single quote (' ) 和逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31785497/