how to call onblur function in asp textbox

Posted by Bhagwati under ASP.NET on 7/5/2012 | Points: 10 | Views : 26493 | Status : [Member] | Replies : 6
how we can call javascript function on asp:textbox blur.

Bhagwati pal


Responses

Posted by: hareeshkumarkr-16190 on: 7/5/2012 [Member] Starter | Points: 25

Up
0
Down
hi ,
hope this will help you...

<style type="text/css">
.redText, .blueText
{
width: 150px;
font-family: Arial;
vertical-align: middle;
}
.redText
{
color: #fff;
}
.blueText
{
color: #888;
}
</style>

<script language="javascript" type="text/javascript">

function changeCssClass(objDivID) {
if (document.getElementById(objDivID).className == 'redText') {
document.getElementById(objDivID).className = 'blueText';
}
else {
document.getElementById(objDivID).className = 'redText';
}
}

</script>

<table>
<tr>
<td width="150" align="right">
Your name&nbsp;<span class="mandatory">*</span>&nbsp;
</td>
<td>
<asp:TextBox ID="TextBox14" runat="server" class="txtboxfreelist" Height="20px" Width="250px"
onfocus="javascript:return changeCssClass('div3')" onblur="javascript:return changeCssClass('div3')"></asp:TextBox>
&nbsp;
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Your Name Required"
ControlToValidate="TextBox14" ValidationGroup="onpr" SetFocusOnError="false"
Text="*" Font-Size="XX-Small" ForeColor="white"></asp:RequiredFieldValidator>
</td>
<td>
<div id="div3" class="redText">
E.g:Ramachandra</div>
</td>
</tr>
</table>


--hareeshkumar--

Bhagwati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vforvijay on: 7/5/2012 [Member] Starter | Points: 25

Up
0
Down
Hi..
Refer the link.
http://www.dotnetcode.in/2012/01/apply-watermark-text-in-textbox-using.html

Bhagwati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Johnbhatt on: 7/5/2012 [Member] Starter | Points: 25

Up
0
Down
This is simple example of onblur code. Apply in any textbox.

onblur="ConvertToDate(this,false)"


John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Bhagwati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 7/6/2012 [Member] Starter | Points: 25

Up
0
Down
http://sandeep-chourasia.blogspot.in/2011/05/onblur-and-onfocus-textbox.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Bhagwati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muralidosscm on: 7/6/2012 [Member] Starter | Points: 25

Up
0
Down
<asp:TextBox id="txtId" runat="sever"></asp:TextBox>

in code behind page

page_load{
this.txtId.Attributes.add("onblur","javascript:funBlur();");
}

Regards
Muralidoss M

Bhagwati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 7/10/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Refer this URL
it will help u.

http://www.codeproject.com/Articles/180355/Calling-a-code-behind-function-from-JavaScript

Bhagwati, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response