html文本框只允许输入数值类型

时间:2026-02-18 05:42:04

1、下载我提供的JQuery文件,可复制html示例运行

2、启主要作用的代码

$('#money').each(function() {

$(this).onlypressNumber();//只允许输入数值类型

//$(this).onlypressInteger();//只允许输入整数

//$(this).onlypressPositiveInteger();//只允许输入正整数

});

3、<!doctype html>

<html>

<head>

<meta charset="UTF-8">

<title>html文本框只允许输入数值</title>

<script src='jquery-1.7.min.js'></script>

<script src='jquery.validate.maximin.js'></script>

</head>

<body>

金额:

<input type='text' id='money' />

</body>

<script>

$('#money').each(function() {

$(this).onlypressNumber();//只允许输入数值类型

//$(this).onlypressInteger();//只允许输入整数

//$(this).onlypressPositiveInteger();//只允许输入正整数

});

</script>

</html>

© 2026 一点资料
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com