I am using jquery on asp.net mvc. I have textbox on page and I hooked up handler for keyup event of textbox. When user deletes the text or pastes text into it, i do not get the handler called.
P开发者_C百科lease help me how to handle this.
EDIT: Also I want to get the value when user pastes the value using mouse.
<input type="text" id="mytextbox" />
<script type="text/javascript">
$(document).ready(function () {
$("#mytextbox")keyup(function(evt) {
evt = evt || event;
switch (evt.keyCode) {
case 8: //Backspace was pressed
alert("Backspace");
break;
case 46: //Delete was pressed
alert("Delete");
break;
case 67:
if (evt.ctrlKey) {
alert("Ctrl-C");
}
break;
case 86:
if (evt.ctrlKey) {
alert("Ctrl-V");
}
break;
default:
alert(evt.keyCode);
break;
}
});
});
</script>
Try moving your keyup
to a change
and see if that helps.
- EDIT -
Have a look at http://archive.devx.com/dhtml/articles/nz012402/nz012402-6.asp as well. most of this is covered in great detail.
精彩评论