ballouta Posted February 13, 2008 Share Posted February 13, 2008 Hello I have a simple html form with two input tags, I set a default value for both, but the problem is that when i opened the form in the explorer and press in one of these fields, the default value stays, I want both fields to be empty when a user clicks inside to write his username and password, how can i do this thanks. <form method="POST" action="login.php"> <input type="text" name="pass" size="15" value="password"> <input type="text" name="email" size="15" value="username"> <input type="submit" value="Login" name="B2"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/90881-input-default-value/ Share on other sites More sharing options...
GameYin Posted February 13, 2008 Share Posted February 13, 2008 I believe this post will deserve a "topic solved" Here is to do that. Onfocus will remove the text box of any text. Onblur will populate the text box with the original text. Check this crap out =] <form method="POST" action="login.php"> <input type="text" name="pass" size="15" value="Password"onblur="if(this.value=='') this.value='Password';" onfocus="if(this.value=='Password') this.value='';" /> <input type="text" name="email" size="15" value="Username" onblur="if(this.value=='') this.value='Username';" onfocus="if(this.value=='Username') this.value='';" /> <input type="submit" value="Login" name="B2"> </form> Copy and paste if you want. This will work money-back guarentee =]. Quote Link to comment https://forums.phpfreaks.com/topic/90881-input-default-value/#findComment-465754 Share on other sites More sharing options...
ballouta Posted February 13, 2008 Author Share Posted February 13, 2008 Thanks It is solved How do I mark the post as Solved?! Quote Link to comment https://forums.phpfreaks.com/topic/90881-input-default-value/#findComment-465880 Share on other sites More sharing options...
GameYin Posted February 13, 2008 Share Posted February 13, 2008 There should be a button next to reply that says "topic solved." I assumed my method worked? Quote Link to comment https://forums.phpfreaks.com/topic/90881-input-default-value/#findComment-465899 Share on other sites More sharing options...
ballouta Posted February 13, 2008 Author Share Posted February 13, 2008 Thanks for you all, yes really deserves to be maked as solved but the button is not found in my page! Regards Quote Link to comment https://forums.phpfreaks.com/topic/90881-input-default-value/#findComment-465921 Share on other sites More sharing options...
GameYin Posted February 13, 2008 Share Posted February 13, 2008 Hmm, that's weird. I'll see if I have a topic solved thing when I make a thread. Quote Link to comment https://forums.phpfreaks.com/topic/90881-input-default-value/#findComment-465992 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.