Thomas Jericho Capuyan Thomas Jericho Capuyan - 2 years ago 89
Javascript Question

How to automatically detect when textbox changes text in my code? TIA

This is my code. How to automatically detect when textbox changes text in my code? TIA

$('input#name').text('content',function() {
var name = $('input#name').val();
if($.trim(name) != ''){
$.post('getphp/getpartnerposition.php', {name: name}, function(data){
$('input#position2').val(data);
});
}
});

Answer Source

Try following code, it might help you

$('input#name').on('change',function()  {
       var name = $('input#name').val();
       if($.trim(name) != ''){
       $.post('getphp/getpartnerposition.php', {name: name}, function(data){
       $('input#position2').val(data);
     });
}
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download