Jump to content

Making a text box do something question?


Redlightpacket

Recommended Posts

This is Javascript, but whatever.  First of all, give the textarea an ID like "sometextarea" with the id attribute.  Then do:

 

<textarea id="sometextarea" onFocus="clear('sometextarea')">Enter some text!</textarea>

 

Then the Javascript would be:

<script type="text/javascript">

function clear(name) {

  elem = document.getElementById(name);

  if (elem.value = elem.defaultValue) {

         elem.value = '';

  }

}

</script>

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.