Woodburn2006 Posted September 11, 2008 Share Posted September 11, 2008 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 More sharing options...
dropfaith Posted September 11, 2008 Share Posted September 11, 2008 http://snippets.dzone.com/posts/show/1256 Link to comment https://forums.phpfreaks.com/topic/123836-clear-form-value-when-clicked/#findComment-639402 Share on other sites More sharing options...
tmbrown Posted September 11, 2008 Share Posted September 11, 2008 onclick="value='';" Example: <input type="text" name="MyTextBox" value="Some Value" onclick="value='';" /> From there on it becomes more complex. Link to comment https://forums.phpfreaks.com/topic/123836-clear-form-value-when-clicked/#findComment-639403 Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 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)" /> Link to comment https://forums.phpfreaks.com/topic/123836-clear-form-value-when-clicked/#findComment-639460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.