`
xiaohee
  • 浏览: 4907 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

The handler of JavaScript

阅读更多
//#########################################################################//
//限制输入框只能输入数字(包括小数)  
//Backspace | Home | End | Delete | Enter These keys are availabale
function checkKey(event) {    
    if(window.event) //whether IE
    {
        if(( event.keyCode>=48 && event.keyCode <=57 ) || (event.keyCode>=95 && event.keyCode<=105) || ( event.keyCode==110 || event.keyCode==8 || event.keyCode==46 || event.keyCode==35 || event.keyCode==36))   
            event.returnValue = true;
        else
            event.returnValue = false;
    }else // FireFox
    {
        if(!((event.which>=48 && event.which<=57) || (event.which>=94 && event.which<=105) || (event.which==110 || event.which==8 || event.which==46 || event.which==35 || event.which==36)))
            event.preventDefault();
    }   
}
0
10
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics