Forum Moderators: open

Message Too Old, No Replies

Password textfield cleverness

Is this possible...?

         

Harley_m

7:41 pm on Feb 20, 2004 (gmt 0)

10+ Year Member



Thanks for helping!

I am trying to be sneaky - I have a login page, on which I have username and password textboxes - which are really great now - since they display Username and Password in the boxes, but upon focus - this text disapears to allow them to enter their input uninterupted - the code for this is (for the password)

<INPUT id="password" onblur="javascript:if(this.value=='') {this.value='Password'}" style="BORDER-RIGHT: #d5d7ff 1px solid; BORDER-TOP: #d5d7ff 1px solid; FONT-SIZE: 11px; BORDER-LEFT: #d5d7ff 1px solid; WIDTH: 135px; COLOR: black; BORDER-BOTTOM: #d5d7ff 1px solid; FONT-FAMILY: verdana; HEIGHT: 18px"

onfocus="javascript:if(this.value=='Password') {this.value='';}" type="text" size="15"

value="Password" name="box" runat="server">

So - works well and is all great - but I was thinking what would be ultra great is if, on focus - it could also change the attribute for type - from text input to password - which would cause the users input to be masked - but the original value "password" - to not be...

the problem arises from the fact that if the text box is set to password - of course any JS value assigned will also be masked - which more than a little spoils the effect!

Is this possible - can one capture the onfocus event for such a text box...?

sorry if this is a supid question!

Harley

RossWal

11:51 pm on Feb 24, 2004 (gmt 0)

10+ Year Member



You probably need 2 controls. Hide one and show the other to toggle from text to password.

HTH,
Ross

txbakers

12:05 am on Feb 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



and, other than being cool, how would that help usability of the page?