onclick method doesnt work for tabbing?

Discussion in 'JavaScript' started by Grimmfang, Aug 15, 2010.

  1. #1
    if (!USER)
      {
         $ret = "
    	 <div id='xlogin'>
             <form method='post' action='$_SERVER[PHP_SELF]'><fieldset>	 
                 <input class='tbox' type='text' name='username' size='15' value='".LAN_THEME_5."' maxlength='20' onclick=\"this.value=''\" />&nbsp;&nbsp;
                 <input class='tbox' type='password' name='userpass' size='15' value='".LAN_THEME_6."' maxlength='20' onclick=\"this.value=''\"/>&nbsp;&nbsp;
                 <input type='hidden' name='autologin' value='1' />
                 <input class='button' type='submit' name='userlogin' value='Login' />
    		 </fieldset></form>
    	 </div>
    PHP:
    This works at removing the text thats already in the field when they click on the field so the user can enter his info without having to manually delete the text in the field. However when the user tabs to the next field he has not clicked it so it is still full of text and must be manually deleted.

    My question is is there some sort of on tab method that could fix this problem?
     
    Grimmfang, Aug 15, 2010 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    The JavaScript events you should be using is onfocus() when entering field, onblur() is fired with exiting if you need it.
     
    digitalpoint, Aug 15, 2010 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,840
    Likes Received:
    4,542
    Best Answers:
    123
    Trophy Points:
    665
    #3
    sarahk, Aug 15, 2010 IP
  4. Grimmfang

    Grimmfang Member

    Messages:
    191
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    #4
    it worked thanks so much :D
     
    Grimmfang, Aug 15, 2010 IP