Jump to content

Js Onblur Onfocus


ckrudelux

Recommended Posts

" theField = this "function clearText(theField)	{	if (theField.defaultValue == theField.value)	theField.value = '';	}function addText(theField)	{	if (theField.value == '')	theField.value = theField .defaultValue;	}

Okay so this script works on my page and at the same time it don't.I have to diffrent pages on the same server both have this script but only one of the pages got it working.The page that don't get this script runing as it should clears the text onfocus but onblur it don't get the text back.At one place where I use this script I get this text then I select the textarea after the input field with the script:[object HTMLInputElement]What is wrong?? No alerts from firebug...

Link to comment
Share on other sites

Show where you call those functions on the text elements.
Here is one of them.
<input title="skriv ett sök ord här." class="topinput" type="text" name="search" onblur="addText(this);" onfocus="clearText(this)" value="Sökord" />

Link to comment
Share on other sites

Print out the value and default value in the addText function to see why it's not setting it.
I added an alert in the first row of the function and it don't even show up.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...