在javascript中设置焦点 [英] setting focus in javascript
本文介绍了在javascript中设置焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hiii全部,
请查看以下javascript:
Hiii All,
Please have a look at the following javascript:
if((document.getElementById("TextBox1").value == "") || (document.getElementById("TextBox1").value == "__/__/____"))
{
alert ( "Invalid Date" );
document.getElementById("TextBox1").value="__/__/____";
document.form1.TextBox1.focus();
return false;
}
在这里,我针对TextBox1的textchanged事件及其工作情况提供了此脚本,但是当我们按Tab键时,它不关注TextBox1..
问候,
here, I am giving this script on textchanged event of TextBox1 and its working but its not focusing on TextBox1 when we press tab ..
Regards,
推荐答案
尝试一下...
try this...
document.getElementById("<%=txtName.ClientID%>").focus();
请参见此 [
var id = document.getElementById('TextBox1'); if((id.value == "") || (id.value == "__/__/____")) { alert ( "Invalid Date" ); id.value="__/__/____"; id.focus(); return false; }
这篇关于在javascript中设置焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文