<script language="JavaScript">
  function checkForm(var age)
  {
    var a = toInt(age);
    return age>=1&&age<=99;
  }
</script><form name="form" onSubmit="return checkForm(document.form.age.value)">
  <input type="text" name="age" maxLength="2"/>
</form>用HTML就可以完成,和JSP无关。

解决方案 »

  1.   

    js 就可以解决
    <script language="JavaScript">
      function checkForm()
      {
        if(document.form.age.value>=1&&document.form.age.value<=100){return ture;}
        else {alert("请输入正确的年龄");return false;}  }
    </script><form name="form" onSubmit="return checkForm()">
      <input type="text" name="age" maxLength="2"/>
    </form>
      

  2.   

    if (object.value >99 || object.value < 1)
    {
       alert("错误");
    }
      

  3.   

    我还有一个小问题:当用户按下提交按钮后数据传到数据库中,如何返回一个message窗口提示用户已成功提交数据呢?