js验证输入的金钱格式
<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>