<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>javascript
文本框只能输入数字-www.jb200.com</title>
<script type="text/javascript">
function regMoney()
{
var MoneyNode = document.getElementById("money");
var reg_money = /^[1-9]d{2,5}[+]{0,1}$/; //以1-9开头,后面还有【0-9】即d二到五个数字,末尾可以有0到1个+号 总共最多7个字符 如123456+
var input_text=MoneyNode.value;//获取id 为money输入框的内容
var mess = reg_money.test(input_text)?"输入符合规格!":"noOk!";//为匹配结果信息赋值
alert(mess);//打印测试
}
</script>
</head>
<body>
<input type="text" id="money" onblur="regMoney()"/>
</body>
</html>