JS:only number(int ,float) can be input
来源:互联网 发布:k means聚类算法 java 编辑:程序博客网 时间:2024/05/22 10:59
//只能输入数字
function CheckInputIsInt(keyCode)
{
if((keyCode>95 && keyCode<106)
|| (keyCode>47 && keyCode<58)
|| keyCode == 8
|| keyCode == 46
|| keyCode == 37
|| keyCode == 39
|| keyCode == 9
|| keyCode == 13) {
}
else {
return false;
}
}
function CheckInputIsFloat(keyCode,e)
{
if((keyCode>95 && keyCode<106)
|| (keyCode>47 && keyCode<58)
|| keyCode == 8
|| keyCode == 46
|| keyCode == 37
|| keyCode == 39
|| keyCode == 9
|| keyCode == 13) {
}
else if (keyCode == 110 || keyCode==190) {
if(e.value == "" || e.value.indexOf(".") != -1) {
return false;
}
}
else {
return false;
}
}
---- using this function in html (only contact with htmlControl)---
<INPUT type="text" id="test" onkeydown="event.returnValue=CheckInputIsFloat(event.keyCode,this)" >
---just like this:
onkeydown="event.returnValue=CheckInputIsFloat(event.keyCode,this)"
onkeydown="event.returnValue=CheckInputIsInt(event.keyCode)"
All KeyCode
- JS:only number(int ,float) can be input
- Error: Q0466E: An output file can only be specified if there is a single input file
- Limit the textbox only can be inputed with number and paste no more than 9 chars
- Null pointer access: The variable number can only be null at this location。 错误解决
- Null pointer access: The variable number can only be null at this location。 错误解决
- 定义了一个数组 int CC [] ={1,2,3}; Array constants can only be used in initializers.
- Only a type can be imported
- Why only SIP INVITE can be CANCELed ?
- Error: Finish can only be called once
- Oracle中INT、FLOAT、NUMBER区别
- Oracle中INT、FLOAT、NUMBER区别
- Can be any number of the Calculator
- js input only allow double type
- Only a type can be imported. resolves to a package
- Array constants can only be used in initializers
- tomcat6异常:Only a type can be imported解决方法
- pure specifier can only be specified for functions
- pure specifier can only be specified for functions
- Fvwm新手入门不完全手册
- 大学生宿舍——中国最昂贵的房价
- JSF与Struts的异同
- CPU基本术语
- 用delphi制作由小到大的动画窗体!
- JS:only number(int ,float) can be input
- 最优雅的不刷新下拉联动解决方案--数据库版--xml版
- 大学生宿舍——中国最昂贵的房价
- 交换机术语
- VB.NET中LISTVIEW排序(原创)
- 一些有用的URL
- blog刚刚开通,还没有耕耘
- logiscope系列-使用说明书
- 正则表达式