admin管理员组文章数量:1290765
I've following textbox which is initially disabled:
<input id="txtCustFName" name="txtRCustFName" type="text" required disabled="true"/>
on click on following anchor tag i m calling the js to enable the above text box: HTML: Enable
JS:
EnableTxt()
{
document.getElementById("txtCustFName").disabled = false;
}
But this code is not working. I am not able to enable text box.
How can I do this?
I've following textbox which is initially disabled:
<input id="txtCustFName" name="txtRCustFName" type="text" required disabled="true"/>
on click on following anchor tag i m calling the js to enable the above text box: HTML: Enable
JS:
EnableTxt()
{
document.getElementById("txtCustFName").disabled = false;
}
But this code is not working. I am not able to enable text box.
How can I do this?
Share Improve this question asked May 13, 2013 at 11:01 Saurabh PalatkarSaurabh Palatkar 3,38412 gold badges52 silver badges112 bronze badges 1- 1 The solution is posted here: stackoverflow./questions/8484181/… – Saravanan Commented May 13, 2013 at 11:03
7 Answers
Reset to default 2Removing the attribute worked allowed me edit the content of the textbox :
document.getElementById("questionnaireText").removeAttribute("disabled");
To set the textbox to disabled
use :
document.getElementById("questionnaireText").setAttribute("disabled", true);
You can enable/disable using this:
function EnableTxt() {
document.getElementById( '<%=txtRCustFName.ClientID%>' ).disabled = 'false';
}
Try this:
function EnableTxt() {
$("#txtCustFName").prop("disabled", false);
}
Here "prop" is used for property/attribute of the tag.
Try this:-
document.getElementById("txtCustFName").setAttribute("disabled", false);
you can do that by setting style using java script
for example:
document.getElementById("txtCustFName").setAttribute("style", "disabled:disabled");
JavaScript
function myfunction(event) {
alert('some anchor clicked');
$('#txtCustFName').prop("disabled",false);
return false;
};
$(document).ready(function(){
$('#myanchorid').click(myfunction);
$('a.anchorclass').click(myfunction);
$('#anchorlist > a').click(myfunction);
});
HTML
<html xmlns="http://www.w3/1999/xhtml" >
<script type="text/javascript" id="Script1" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript" id="myScript" src="myScript.js"></script>
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<a id="myanchorid" href="#">Click Me</a><br />
<a class="anchorclass" href="#">Click Me</a><br />
<input id="txtCustFName" name="txtRCustFName" type="text" required disabled="true"/><br />
<div id="anchorlist">
<a href="#">Click Me</a>
<a href="#">Click Me</a>
<a href="#">Click Me</a>
</div>
</div>
</form>
</body>
</html>
Try this....this will resolve your problem...
You should use the attribute of the textbox.
jQuery:
($this.attr('disabled')) $this.removeAttr('disabled');
Please note that this is not supported in IE6
本文标签: cEnabling text box using javascriptStack Overflow
版权声明:本文标题:c# - Enabling text box using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741503296a2382173.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论