Print this page
Saturday, 02 February 2013 13:54

how to show textbox hint when textbox empty by jquery

Written by 
Rate this item
(0 votes)

It's a very common requirement to show hint in textbox when empty
and when textbox gets focus hint goes away.now a days many websites
implemented showing hint.there are many ways to do that by jquery.

by the following example i am going to show how one can show
hint in textbox in easier way.you may find better example for
that in internet but this one is good enough...

function MitsolReplyBoxFocus(caller) {
var id = caller.id;
if ((jQuery(".NameTextBox").val() == "name")) { jQuery(".NameTextBox").val(""); }
}
function MitsolReplyBoxBlur(caller) {
var id = caller.id;
if ((jQuery(".NameTextBox").val() == "")) { jQuery(".NameTextBox").val("name"); }
}

function pageLoad() {
jQuery(".NameTextBox").val("name");
};

in page -

<input type='text' id='NameTextBox1' class="NameTextBox" onfocus='MitsolReplyBoxFocus(this)'
onblur='MitsolReplyBoxBlur(this)' value="name" runat="server"/>

for my application in pageLoad function i did not put any condition because
every page load i am begining everything.you may put condition if
necessary.

Read 3287 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
7