http://www.csdn.net/develop/Read_Article.asp?Id=17907

解决方案 »

  1.   

    不明白,我用的是JSP,这方面要用javascript的,我不懂javascript,书上原封抄的。
    如果直接
    <script language=javascript type=text/javascript>
    <!-alert("请输入一个整数!");
    //->
    就可以运行,不明白为什么?
      

  2.   

    <form name=pig method="post" onsubmit="return isInt(this)
     action="checkgetmoney.jsp">把form改称这样试试
      

  3.   

    shdxy说的没错,函数isInt(this)返回false时form才不会提交到下一页,如果函数返回true或者函数里面的javascript执行出错或者函数没有返回值,form都会向下一页进行提交。
      

  4.   

    javascript程序是在客户端执行的,不需要和服务器打交道
    用javascript可以在你提交前对数据进行检查。上面shdxy是对的,
    编写bs程序最好懂得javascript,很简单的
      

  5.   

    function isDigit(theNum)
    {
    var theMask='0123456789';
    if(isEmpty(theNum)) return(false);
    else if(theMask.indexOf(theNum)==-1) return(false);
    return(trun);//true 吧?
           ^^^^--------------??
    }
      

  6.   

    你这个函数不是用来判断整数的吧,只是判断是整数字符串的。
    题外话
    可以把
    <input type="submit" name="submit1" value="提款">
    改成
    <input type="submit" name="submit1" value="提款" onclick="return IsgettenInt()">然后添加一个函数
    function IsgettenInt()
    {
      var strValue = pig.getten.value;
      if (IsEmpty(strValue))
      {
        return (false);
      } 
      strValue=parseInt(strValue );
      if (strValue != "NaN")  //不是整数
      {
        return (true);
      }
      else
      {
        window.alert("请输入整数");
        return (false);
      }
    }