$(‘input[type=number]’).keypress(function(e) {
     
     
     if (!String.fromCharCode(e.keyCode).match(/[0-9\.]/)) {
     
     
     return false;
     
     }
     
     });
    
fromCharCode()是String的一个方法,可接受一个指定的Unicode值,返回一个字符串
使用方法:String.formCharCode()
转载于:https://www.cnblogs.com/senyu/p/7125565.html
 
