Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Specify password criteria in ASP

Explorer ,
Aug 22, 2006 Aug 22, 2006

Copy link to clipboard

Copied

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
TOPICS
Server side applications

Views

280
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 22, 2006 Aug 22, 2006

Copy link to clipboard

Copied

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



Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 22, 2006 Aug 22, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 22, 2006 Aug 22, 2006

Copy link to clipboard

Copied

LATEST
I think it needs to use a 1 based counter rather than a zero based counter.
Try this instead:

i = 1
While i <= Len(varPassword)

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



Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines