function keyPressInt(src){
var e=window.event;
code=e.keyCode;
if(code >=48 && code <=57) return true;
else {window.event.keyCode=null;return false;}
}
function keyPressFlt(src){
var e=window.event;
code=e.keyCode;
if(code >=48 && code <=57) return true;
else if(code == 46 && src.value.indexOf('.')==-1) return true;
else{ window.event.keyCode=null; return false; }
}
第一个输入整数
第二个输入浮点数
调用方法:
<input type="text" onKeyPress="keyPressInt(this)".....
var e=window.event;
code=e.keyCode;
if(code >=48 && code <=57) return true;
else {window.event.keyCode=null;return false;}
}
function keyPressFlt(src){
var e=window.event;
code=e.keyCode;
if(code >=48 && code <=57) return true;
else if(code == 46 && src.value.indexOf('.')==-1) return true;
else{ window.event.keyCode=null; return false; }
}
第一个输入整数
第二个输入浮点数
调用方法:
<input type="text" onKeyPress="keyPressInt(this)".....
解决方案 »
- 怎样输出四个数的最大最小值,用JS完成
- JS做分页,数据很大,速度很慢,怎么办?
- 请教: 当鼠标移至链接时, 如何显示该链接的预览(有答案加分结帐)
- 高分请高手帮忙,最近读到一个js程序,没弄懂请高手帮一下
- 请问:一个1.htm里面包含有2个IFRAME--2.htm和3.htm,怎样在2.htm里面写js访问3.htm里面的对象(比如表格)?谢谢!
- 这样的一段程序应该怎么写。
- (求教)JS中关于数组存储数据的问题(在线等)
- 各位大哥还请多多帮忙!!
- javascript怎樣才能將string 變成int?
- photoswipe做的图片效果,下面四个按钮PC可以出来,手机端出不来!
- 急求检查表单文件域合法性的函数
- 发布我的作品Myhyli's Outlook
ptn.test(你的字符串)
或
ptn.exec(你的字符串
)
Description: Matches euro currency (portuguese regional options). Uses the dot sign as the thousands separator (optional) and the comma sign as the decimal separator. Matches only 2 digitals after decimal. Also matches negative numbers.
Matches: [-123123,12 €], [12312432134], [-12.234.123,23] [ More Details]
Non-Matches: [1234.12,234]
http://www.regexlib.com:好多正则表达式。