Jump to content

Recommended Posts

I have a login form with 2 input text boxes and their values are set to username and password initally so if a user clicks on one i want clear that input box and if no value is entered in theother input box then make sure that that other input boxes value is either username or password, here is what i have so far, it half works although if you actually type in a username or password and click the other box then it is cleared which i don't want,

 

<form action ="post" method ="?login" >

<input type = "text" value = "username" id ="u1" 

onfocus="this.value='';document.getElementById('p1').value='password'" >
<input type = "text" value = "password" id ="p1" 

onfocus="this.value='';document.getElementById('u1').value='username'">

</form>

 

 

So like say if "the other box" doesn't have a password or username entered then then make it's value back to username or password.

<form action ="post" method ="?login" >
<input type = "text" value = "username" id ="u1" onfocus="this.value='';" onblur="this.value=this.value===''? 'username':this.value;">
<input type = "text" value = "password" id ="p1" onfocus="this.value='';" onblur="this.value=this.value===''? 'password':this.value;">
</form>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.