JavaScript:
$("input").keydown(function (event) {
let key = event.which;
//console.log(key,'key');可在此打開註解檢查KEY碼
//倒退,左右鍵、HOME、END、DEL處理,無條件通過
if(key==8 || key==37 || key==39 || key==35 || key==36 || key==46){
return true;
}
//0~9鍵及-鍵及數字盤鍵處理判斷處理
if ( !( (key >= 48 && key <= 57) || key == 109 || (key >= 96 && key <= 105) || key == 189 )) {
return false;
}
});