rv20 Posted May 21, 2009 Share Posted May 21, 2009 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. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 21, 2009 Share Posted May 21, 2009 How is someone supposed to log in with that with JavaScript enabled? As soon as I click the password field, you changed my username to username. :-\ Quote Link to comment Share on other sites More sharing options...
rv20 Posted May 21, 2009 Author Share Posted May 21, 2009 How is someone supposed to log in with that with JavaScript enabled? As soon as I click the password field, you changed my username to username. :-\ EXACTLY that is what i am trying to correct, i need more js but am stuck. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 21, 2009 Share Posted May 21, 2009 <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> Quote Link to comment Share on other sites More sharing options...
rv20 Posted May 21, 2009 Author Share Posted May 21, 2009 nice, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.