Question

I've tried the jQuery and JavaScript solutions here:

How to clear text field on focus of text field

All of which work, but not on FF 3.6 for some odd reason. SO! What can I use for this feature to work on FF 3.6 / that generation older browsers?

I'd like the search field to display my styled default text, and when the user clicks inside the field, the text would disappear, and when clicked back out - it should reappear again. Just as they all do nowadays.

Thanks for any help

Update: Have just tried this JS; and it rendered there at first in 3.6, but after clicking in field and out it never came back. Also, after refreshing, and even clearing cache it hadn't came back again??

<html>
<head>
<title>Clear Form Demo</title>

<script language="javascript">
<!--
function ClearForm() {
  document.testform.email.value= "";
}

//-->
</script>

</head>

<body>

<form name="testform">
    <input type="text" name="email" value="Something here." onfocus="ClearForm();">
</form>
</body>
</html>
Was it helpful?

Solution

I would have said HTML5 placeholder attribute immediately, but that isn't supported in Firefox 3.6 as well. Here is a fix using jQuery for all other browsers. You can try it out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top