<html>
<head>
<title>js验证输入的金钱格式</title>
<script type="text/javascript">
function moneyCheck(){
var isNum = /^\d+(\.\d+)?$/;
var money = document.getElementById("money").value;
if(!isNum.test(money)){
alert("请输入正确的金钱");
return;
}else{
alert("输入正确");
}
}
</script>
</head>
<body>
<input id="money" type="text" name="">
<button onclick="moneyCheck();">验证</button>
</body>
</html>
转载于:https://www.cnblogs.com/qhorse/p/5415850.html