KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Creating your own password entry area
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: June 1, 2001
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

In most applications that require the user to login to the system, you will notice that all characters that the user types in the password field are converted into symbols. This is to protect the password from being seen by others. In 4D, you can produce the same behavior with the following Object Method attached to an enterable variable named 'vPswd' on your form:

Case of
: (Form event=On Load )
C_TEXT($tempString;vPswd;vActualValue)
C_INTEGER(vlastPosition)
$tempString:=""
vPswd:="" ` The user will only see the content of this variable.
vActualValue:="" ` The actual text value that user typed in.
vlastPosition:=0
: (Form event=On After Keystroke )
$tempString:=Get edited text
If (Length($tempString)>vlastPosition)
vlastPosition:=Length($tempString)
vPswd:=""
For ($i;1;vlastPosition)
vPswd:=vPswd+"#"
End for
If (vlastPosition>1)
$tempString:=Delete string($tempString;1;vlastPosition-1)
End if
vActualValue:=vActualValue+$tempString
Else
vActualValue:=Delete string(vActualValue;vlastPosition;vlastPosition)
vlastPosition:=vlastPosition-1
End if
End case