WaterMark a Text box Using javascript

Maheshbabu
Posted by Maheshbabu under JavaScript category on | Points: 40 | Views : 523
Introduction:
In Ajax toolkit there is watermark extender that can be added with textbox by which whenever textbox is focused the default text written in it get cleared. The same thing you can do with JavaScript use more of the JavaScript or jquery rather than using ajax toolkit as it slow down the server speed to let the page render.

Code:

<script  language="javascript">
functionSetWaterMark(txtboxname,evnt)
{
var el=document.getElementById(txtboxname);
if(evnt=="focus")
if(el.value.toUpperCase()==wtrmrk.toUpperCase())
el.value="";
else
el.select();
else if(el.value=='')
el.value=wtrmrk;
}
</script>


For more codesnippets,visit:http://www.dotnetchallengers.com/App_Folder/Home/CodeSnippets.aspx

Comments or Responses

Login to post response