Detecting Change In A Text Input Box Using Jquery/javascript
in html and javascript, I can use keyup, focus, blur to detect most of the content changes in a text input, however if the user do a copy and paste into the text input, how do I ca
Solution 1:
You could capture the paste event (http://www.quirksmode.org/dom/events/cutcopypaste.html)
$("#myinput").bind("paste",function(){
//code here
})
Solution 2:
$("#myinput").change(function(){
// whatever you need to be done on change of the input field
});
// Trigger change if the user type or paste the text in the field
$("#myinput").keyup(function(){
$(this).change();
});
// if you're using a virtual keyboard, you can do :
$(".key").live('click',function(){
$("#myinput").val($("#myinput").val()+$(this).val());
$("#myinput").change(); // Trigger change when the value changes
});
Solution 3:
the textbox has an OnChange event that fires when a) the text box loses focus AND the value within the text box has changed.
Post a Comment for "Detecting Change In A Text Input Box Using Jquery/javascript"