.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

WaterMark Text box with javascript

Posted By:Rajshree       Posted Date: October 01, 2010    Points: 15    Category: Javascript    URL: http://www.dotnetspark.com  

Hi In Ajax tool kit there is watermark extender that can be added with textbox by which whenever textbox is focused the defualt 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 speed to let the page render.
 

Here is the code:

function SetWaterMark(tbNm, evnt)
{
    var el =  document.getElementById(tbNm);              
    if(evnt=="focus")
        if(el.value.toUpperCase()==wtrmrk.toUpperCase())
            el.value="";
        else
            el.select();   
    else if(el.value=='')   
            el.value=wtrmrk;
   
}







     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend