JS input 数字验证代码_javascript技巧
程序员文章站
2024-01-27 16:27:40
...
/*
**@控制控件只能输入数字,含-(负号).(小数点)
**@Inline HTML: For Input
**@Event property: object.attachEvent("onkeypress",onlyNumber);object.style.imeMode = "disabled";
**@Author:wangwq@atools
*/
function onlyNumber(){
if(!(((window.event.keyCode >= 48) && (window.event.keyCode || (window.event.keyCode == 13) || (window.event.keyCode == 46)
|| (window.event.keyCode == 45))){
window.event.keyCode = 0 ;
}
}
// 本函数用于限制文本输入框中只能输入数字"0"到"9"
//@Inline HTML: For Input
//@Event property: object.attachEvent("onkeypress",JHshNumberText);object.style.imeMode = "disabled";
function JHshNumberText()
{
if ( !(((window.event.keyCode >= 48) && (window.event.keyCode {
window.event.keyCode = 0 ;
}
}
**@控制控件只能输入数字,含-(负号).(小数点)
**@Inline HTML:
**@Event property: object.attachEvent("onkeypress",onlyNumber);object.style.imeMode = "disabled";
**@Author:wangwq@atools
*/
function onlyNumber(){
if(!(((window.event.keyCode >= 48) && (window.event.keyCode || (window.event.keyCode == 13) || (window.event.keyCode == 46)
|| (window.event.keyCode == 45))){
window.event.keyCode = 0 ;
}
}
// 本函数用于限制文本输入框中只能输入数字"0"到"9"
//@Inline HTML:
//@Event property: object.attachEvent("onkeypress",JHshNumberText);object.style.imeMode = "disabled";
function JHshNumberText()
{
if ( !(((window.event.keyCode >= 48) && (window.event.keyCode {
window.event.keyCode = 0 ;
}
}
推荐阅读
-
JS input 数字验证代码_javascript技巧
-
JS对select控件option选项的增删改查示例代码_javascript技巧
-
js获取url中指定参数值的示例代码_javascript技巧
-
js 判断上传文件大小及格式代码_javascript技巧
-
Js setInterval与setTimeout(定时执行与循环执行)的代码(可以传入参数)_javascript技巧
-
js调用webservice中的方法实现思路及代码_javascript技巧
-
js实现单一html页面两套css切换代码_javascript技巧
-
js防止表单重复提交实现代码_javascript技巧
-
js prototype 格式化数字 By shawl.qiu_javascript技巧
-
JS的数组的扩展实例代码_javascript技巧