Click here to Skip to main content
15,900,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
var textbox= document.getElementById ("textbox");
if (textbox.value == "") {
alert("You did not enter text in the textbox. Please enter before submitting form. \n");
textbox.focus();
return false;
}

HTML -

<input name="textbox" type="text" value="Click here to type" onfocus="if(this.value=='Click here to type')this.value='';" onblur="if(this.value=='')this.value='Click here to type';">



Regarding
..........
Posted
Updated 22-May-12 0:08am
v2
Comments
Arunprasath Natarajan 22-May-12 6:12am    
Which version u r using
vignesh9894620769 22-May-12 6:21am    
ie8

1 solution

Dear Friend,

I use the same, use this hope it works.

HTML
<input type="text" name="filter" onfocus="searchfield_focus(this)" onBlur="fun_return(this)" value="Enter The Text To Search">


JavaScript
<script language="javascript">
function searchfield_focus(obj)
{
	obj.style.color=""
	obj.style.fontStyle=""
	if (obj.value=="Enter The Text To Search")
	{
		obj.value=""
	}
}
function fun_return(obj)
{
	if (obj.value=="")
	{
		obj.style.color="#808080"
		obj.style.fontStyle="italic"
		obj.value="Enter The Text To Search"
	}
}
</script language="javascript">


Regards,
AP
 
Share this answer
 
v2
Comments
vignesh9894620769 23-May-12 6:10am    
Hai are you checking IE8 . this is not woking

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900