用户输入格式验证,必须是这种格式:
整形,整形在程序里怎么写?

解决方案 »

  1.   

    String s = "123,345";
    boolean f = s.matches("[0-9]+,\\d+");
    System.out.println(f);
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <script language="JavaScript">
    <!--
    function test(obj) {
      var myReg = /^(\+|\-)?(\d+\.?\d*|\.\d+)$/;  if(!myReg.test(obj.value)) {//    obj.focus();    alert('false');
      }
    else {
        alert('true');
    }
    }

    //-->
    </script>
    </head>
    <body>
    <form method=post action="">
    <input type="text" name="aaa">
    <input type="button" onclick="test(aaa)" value="test">
    </form>
    </body>
    </html>