keypress 이벤트

1495 단어 key
 1 var textbox = document.forms[0].elements["textbox1"];

 2 

 3 // 

 4 EventUtil.addHandler(textbox, "keypress", function(event) {

 5     event = EventUtil.getEvent(event);

 6     var target = EventUtil.getTarget(event);

 7     var charCode = EventUtil.getCharCode(event);

 8 

 9     if (!/\d/.test(String.fromCharCode(charCode)) && charCode > 9 && !event.ctrlKey) {

10         EventUtil.preventDefault(event);

11     }

12 });

좋은 웹페이지 즐겨찾기