Jump to content

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

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.