Skip to main content
Inspiring
August 22, 2006
Question

Specify password criteria in ASP

  • August 22, 2006
  • 1 reply
  • 324 views
Can anyone tell me how to enforce a password criteria of say at least six characters and one number when users renew there password I am using ASP vbscript with a SQL DB. Any ideas much appreciated, Thanks in Advance TheBOSMan
This topic has been closed for replies.

1 reply

Inspiring
August 22, 2006
Some VBScript code along these lines...

<%
Dim varPassword, varCharacter ' Strings
Dim varContainsANumber ' Boolean
Dim i ' Integer
varPassword = Request.Form("password")
varContainsANumber = False
If varPassword <> "" And Not IsNull(varPassword) Then
' Password was entered - check length
If Len(varPassword) >= 6 Then
' Password is 6 characters or longer
' Check that at least one number is present
' Loop through string and test each character to see if it is
numeric
i = 0
While i < Len(varPassword)
varCharacter = mid(varPassword, i, 1)
If IsNumeric(varCharacter) Then
' Number found, set flag to true
varContainsANumber = True
End If
i = i + 1
Wend
If varContainsANumber Then
' Password has passed criteria checks... do stuff...
Else
' Password failed criteria checks
' Return an appropriate error message to the user
End If
Else
' Password is shorter than 6 characters
' Return an appropriate error message to the user
End If
Else
' Password was not entered
' Slap user with a large fish
End If
%>

Something like that - off the top of my head - untested!! :)
HTH
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav



TheBOSMANAuthor
Inspiring
August 22, 2006
thats great works fine except the area that checks for the number, get this error for the mid command

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument: 'mid'

Any ideas appreciated.