Jump to content

Input Default value


ballouta

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/90881-input-default-value/
Share on other sites

I believe this post will deserve a "topic solved"  ;D

 

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  =].

Link to comment
https://forums.phpfreaks.com/topic/90881-input-default-value/#findComment-465754
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.