Jump to content

Recommended Posts

this seems really simple but i cannot seem to find this anywhere on the net but when i have a value in a form field i want it to disappear when a user clicks in the field to add their own value, i see it everywhere but cannot find the method of doint it myself

 

thanks alot

Link to comment
https://forums.phpfreaks.com/topic/123836-clear-form-value-when-clicked/
Share on other sites

tmbrown, that'll clear it out even if the user has the content that they want in the box.  You need to make sure that there isn't the default value in there:

 

<script type="text/javascript">
function clearThis(element) {
   if (element.defaultValue == element.value) {
      element.value = '';
   }
}
</script>

<input type="text" name="someinput" value="Enter something here!" onclick="clearThis(this)" />

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.