Discussion Locked

Password length

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello,
How do I set the parameters for a word length?
For instance, I want ALL passwords entered to be no shorter than 12 characrters, but no longer than 15 characters...

10 replies

by tg2

Just a guideline, you'll do better to be careful where you are spec'ing the password requirements.

some applications come designed for longer passwords, others, well.. solaris in a default configuration only looks at the first 8 characters. Password issues resound in all things..

your better bet would be to restrict passwords to have at least one number, and one symbol with a total required length of 8 characters, also disallow duplicate's, like no:
aaaa1.aa
a111111.
a1a1a1a.

do simple things to make the normal 8 characters more difficult.. no dictionary words.. etc..

also.. what platform (assuming you are programming) or what application (since you HAVE posted to the Software message board)

by ann777

Please remove the space embedded in the portion "url=/library/" above when pasting the link into your browser.

by timfox2

Two options. Indert code directly into the form's code that deals with each password entry individually or put the rule into a global function that tests the specific field.

Option 1.

Private Sub txtPassword_LostFocus()
If Len(txtPassword) < 12 Or Len(txtPassword) > 15 Then
MsgBox "Password invalid. Must consist of more than 11 characters and less than 15 characters"
End If
End Sub

Option 2.

or paste this in a module:

Public Function PasswordIsNotValid(strFieldName As String) As Boolean
If Len(txtPassword) < 12 Or Len(txtPassword) > 15 Then
PasswordIsValid = True
Else
PasswordIsValid = False
End If
End Function

and use it by pasting this into the form's code:

Private Sub txtPassword_LostFocus()
If PasswordIsNotValid("forms!frmThisForm.txtPassword") Then
MsgBox "Password invalid. Must consist of more than 11 characters and less than 15 characters"
End If
End Sub

Hope this helps
TimFox2

by timfox2

Using the BeforeUpdate field event will allow you to keep the user in the txtPassword field until they enter the correct string length...

Private Sub txtPassword2_BeforeUpdate(Cancel As Integer)
If PasswordIsNotValid("forms!frmThisForm.txtPassword") Then
MsgBox "Password invalid. Must consist of more than 11 characters and less than 15 characters"
DoCmd.CancelEvent
End If
End Sub

by timfox2

Using the BeforeUpdate field event will allow you to keep the user in the txtPassword field until they enter the correct string length...

Private Sub txtPassword2_BeforeUpdate(Cancel As Integer)
If PasswordIsNotValid("forms!frmThisForm.txtPassword") Then
MsgBox "Password invalid. Must consist of more than 11 characters and less than 15 characters"
DoCmd.CancelEvent
End If
End Sub

This discussion is closed to new replies.