使用javascript禁用文本框 [英] disable the textbox using javascript

查看:79
本文介绍了使用javascript禁用文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有textbox。当我在文本框中输入值并使用选项卡转到另一个文本框时,此文本框已禁用。为此我在.js文件中使用了javascript这样的..

 function TotalFeesDesable()
{
document.getElementById(ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_totalfees)。Enabled = false;

}









< asp:TextBox ID =txt_totalfeesrunat =serveronblur =TotalFeesDesable()>< / asp:TextBox> 





但它不能正常工作。我的代码有什么问题?

解决方案

首先,你必须使用正确的控制ID - 检查 Control.ClientID 属性: http:// msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx [ ^ ]



其次,正确的DOM财产是禁用;启用是WebForm的属性!


它应显示为:



 document.getElementById( ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_totalfees)。disabled = true; 



 <   asp:TextBox     ID   =  txt_totalfees    runat   =  server    onblur   =  javascript:return TotalFeesDesable() >  <   / asp:TextBox  &g吨;  


i have textbox.when i enter value in textbox and goto another textbox using tab,this textbox disabled.for this i have use javascript in .js file like this..

function TotalFeesDesable()
{
document.getElementById("ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_totalfees").Enabled=false;

}



and

<asp:TextBox ID="txt_totalfees" runat="server" onblur="TotalFeesDesable()"></asp:TextBox>



but it is not working.what is problem in my code?

解决方案

First, you have to use proper control ID - check Control.ClientID property: http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx[^]

Second, the correct DOM property is "disabled"; enabled is WebForm''s property!


It should read:

document.getElementById("ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_totalfees").disabled = true;


<asp:TextBox ID="txt_totalfees" runat="server" onblur="javascript: return TotalFeesDesable()"></asp:TextBox>


这篇关于使用javascript禁用文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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