<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>编程素材网</title>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
//文本框只能输入数字(包括小数),并屏蔽输入法和粘贴
jQuery.fn.number=function(){
this.bind("keypress",function(e){
var code=(e.keyCode?e.keyCode:e.which); //兼容火狐 IE
//火狐下不能使用退格键
if(!$.browser.msie&&(e.keyCode==0x8)){return;}
if(this.value.indexOf(".")==-1){return (code >= 48 && code<= 57)||(code==46);}
else{return code >= 48 && code<= 57}
});
this.bind("paste",function(){return false;});
this.bind("keyup",function(){
if(this.value.slice(0,1) == ".")
{
this.value = "";
}
});
this.bind("blur",function(){
if(this.value.slice(-1) == ".")
{
this.value = this.value.slice(0,this.value.length-1);
}
});
};
$(function(){
$("#txt").number();
});
</script>
</head>
<body>
<input type="text" id="txt" />
</body>
</html>
<html>
<head>
<meta charset="gb2312">
<title>蚂蚁部落</title>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
//文本框只能输入数字(不包括小数),并屏蔽输入法和粘贴
jQuery.fn.integer=function(){
this.bind("keypress",function(e){
var code=(e.keyCode?e.keyCode:e.which); //兼容火狐 IE
//火狐下不能使用退格键
if(!$.browser.msie&&(e.keyCode==0x8))
{
return ;
}
return code >= 48 && code<= 57;
});
this.bind("paste",function(){
return false;
});
this.bind("keyup",function(){
if(/(^0+)/.test(this.value))
{
this.value = this.value.replace(/^0*/,'');
}
});
};
$(function(){
$("#txt").integer();
});
</script>
</head>
<body>
<input type="text" id="txt" />
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有