Reputation: 313
I have piece of html code as well as script code. I need solution to handle on change event of one text box that disable act of inputting data in another text field. Could any one help me in regarding.
<div id="cca" class="leaf">
<label class="control input text" title="">
<span class="wrap">cca</span>
<input class="" type="text" value="[Null]"/>
<span class="warning"></span>
</label>
</div>
<div id="ccit" class="leaf">
<label class="control input text" title="">
<span class="wrap">ccit</span>
<input class="" type="text" value="[Null]"/>
<span class="warning"></span>
</label>
</div>
$(document).ready(function () {
alert("hello");
$("#cca").on('change', 'label.control input', function (event) {
alert('I am pretty sure the text box changed');
$("ccit").prop('disabled',true);
event.preventDefault();
});
});
Upvotes: 5
Views: 77652
Reputation: 10121
You can also use attr
on the line $("ccit").attr('disabled',true);
if prop
gives you an error
Upvotes: 0
Reputation: 16116
For one you were missing #
on your $("ccit")
$(document).ready(function () {
alert("hello");
$("#cca").change(function(){
alert('I am pretty sure the text box changed');
$("#ccit").prop('disabled',true);
event.preventDefault();
});
});
Update
$(document).ready(function () {
$("#cca").on('change', 'label.control input', function (event) {
alert('I am pretty sure the text box changed');
$("#ccit").find('label.control input').prop('disabled',true);
event.preventDefault();
});
});
Update 2
$(document).ready(function () {
$(document).on('change', '#cca label.control input', function (event) {
alert('I am pretty sure the text box changed');
$("#ccit").find('label.control input').prop('disabled',true);
event.preventDefault();
});
});
Upvotes: 10