选中复选框时如何启用/禁用文本框 [英] how to enable/disable textbox when check the checkbox
本文介绍了选中复选框时如何启用/禁用文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下编码来启用/取消用户选中复选框时的文本框。默认情况下,当用户检查必须启用时,应该禁用它。我尝试了这个但是没有工作。
(注意:默认情况下它处于禁用模式,但当我选中复选框时仍然处于禁用模式)
< script src = ../ js / jquery.min.js type = text / javascript > < ; / script >
< script src = ../ js / global-script.js type = text / javascript > < / script >
< script src = ../ js / jquery-1.5.js 类型 = text / javascript > < / script >
< script language = javascript type = text / javascript >
$(document).ready(function(){
$(input [type = textbox] [id * = txtfrmDate])。attr(disabled,true);
$(input [type = checkbox] [id * = ChkDate])。click(function(){
if(this.checked)
$(this) .closest(tr)。find(input [type = text] [id * = txtfrmDate])。attr(disabled,false);
else
$(this).closest (tr)。find(input [type = text] [id * = txtfrmDate])。attr(disabled,true);
});
});
< asp:TextBox ID = txtfrmDate runat = server CssClass = txtbox datebox 样式 = z- index:98; width:100px; > < / ASP:文本框 >
解决方案
(文件).ready( function(){
(input [type = textbox] [id * = txtfrmDate])。attr(disabled,true);
< blockquote>(input [type = checkbox] [id * = ChkDate])。click(function(){
if(this.checked)
i used below coding to enable/disbale textbox when user check checkbox. by default it should be disable when user check it have to be enable. i tried this but not working.
(Note: by default its in disable mode but when i check the checkbox still in disable mode)
<script src="../js/jquery.min.js" type="text/javascript"></script>
<script src="../js/global-script.js" type="text/javascript"></script>
<script src="../js/jquery-1.5.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$("input[type=textbox][id*=txtfrmDate]").attr("disabled", true);
$("input[type=checkbox][id*=ChkDate]").click(function() {
if (this.checked)
$(this).closest("tr").find("input[type=text][id*=txtfrmDate]").attr("disabled", false);
else
$(this).closest("tr").find("input[type=text][id*=txtfrmDate]").attr("disabled", true);
});
});
<asp:TextBox ID="txtfrmDate" runat="server" CssClass="txtbox datebox" Style="z-index: 98; width: 100px;"> </asp:TextBox>
解决方案
(document).ready(function() {
("input[type=textbox][id*=txtfrmDate]").attr("disabled", true);
("input[type=checkbox][id*=ChkDate]").click(function() { if (this.checked)
这篇关于选中复选框时如何启用/禁用文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文