在asp.net中留下文本框的事件 [英] leave event of text box in asp.net

查看:68
本文介绍了在asp.net中留下文本框的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有



i有三个文本框。第三个文本框是只读的。现在我想要当用户在第二个文本框中输入一个值然后一个离开事件是已经解雇了两个文本框(第一个和第二个)共有第三个只读文本框



实际上我想调用第三个文本框的离开事件并得到总数使用java脚本。

如何使用javscript实现

hi all

i have three text boxes.third text box is read only.Now i want when user enter a value in second text box then a leave event is fired and the total of two text boxes(first and second) is get in third readonly text boxes

actually i want to invoke leave event of third text box and get total using java script .
how to implement using javscript

推荐答案

您可以在onblur事件的帮助下实现离开事件。附上第二个文本框的onblur事件,现在当用户离开第二个文本框时,onblur事件事件将被触发,您可以根据您的要求在此事件中执行任何操作。



参见onblur事件示例:

Link 1 [ ^ ]

< a href =http://www.w3schools.com/jsref/event_onblur.asp>链接2 [ ^ ]
You can implement leave event as you are saying with the help of onblur event. Attach onblur event of your second textbox, now when user leaves second textbox, onblur event event will be fired and you can do ehatever you on this event as per your requirement.

see example of onblur event:
Link 1[^]
Link 2[^]


Textbox TextChanged没有触发。虽然我给了Autopostback ='True
Textbox TextChanged is not firing.even though i gave Autopostback='True"


你可以这样做



you can do like

<html>
<head>
<script>
function myFunction()
{
var val1=document.getElementById("txtid1");
var val2=document.getElementById("txtid2");
var total="";
if(!isNaN(val1 ) && !isNaN(val2)){
total=val1+val2;
('txtid3').html(total);
}
}
</script>
</head>
<body>

<p>A function is triggered when the user is pressing a key in the input field.</p>

<input type="text" onkeypress="myFunction()">

</body>
</html>

这篇关于在asp.net中留下文本框的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆