1
我正在嘗試做一個簡單的整數數字輸入掩碼,而不必包含像Digital Bush's masked input這樣的整個插件。jQuery數字輸入掩碼
下面是我從另一個計算器問題「改變用途」的代碼:
$('input[name=Qty]').keyup(function() {
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode(key);
var regex = '[0-9]'; /* Use |\. to include a decimal */
if(!regex.test(key)) {
theEvent.returnValue = false;
theEvent.preventDefault();
}
});
的錯誤是在第一線,在它不知道什麼是EVT。
我想我需要使用$(this)的東西。