easy watermark in asp.net with javascript

Step 1: Given below script help u make a Custome Water Mark

<script type = “text/javascript”>

var defaultText = “Enter your text here”;

function WaterMark(txt, evt)


if(txt.value.length == 0 && evt.type == “blur”)


txt.style.color = “gray”;

txt.value = defaultText;


if(txt.value == defaultText && evt.type == “focus”)


txt.style.color = “black”;




Step2:  CALL THIS script  in textbox onblur function

<asp:TextBox ID=”TextBox1″ runat=”server” Text = “Enter your text here”

ForeColor = “Gray” onblur = “WaterMark(this, event);”

onfocus = “WaterMark(this, event);”>


Step 3 :Now Add it Into Attribute of TextBox Into Page Load

TextBox1.Attributes.Add(“onblur”, “WaterMark(this, event);”);

TextBox1.Attributes.Add(“onfocus”, “WaterMark(this, event);”);


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s