Thomas Jericho Capuyan Thomas Jericho Capuyan - 1 year ago 76
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);
     });
}
});