写一个Bean去做就可以了啊。
Javascript也可以啊

解决方案 »

  1.   

    我的做法是使用javascript.只能输入数字:
    function onlynumber(str)
    {
      var i,strlength,tempchar;
      str=CStr(str);
      if(str=="") return false;
      strlength=str.length;
      for(i=0;i<strlength;i++)
      {
        tempchar=str.substring(i,i+1);
        if(!(tempchar==0||tempchar==1||tempchar==2||tempchar==3||tempchar==4
    ||tempchar==5||tempchar==6||tempchar==7||tempchar==8||tempchar==9))
        {
        alert("只能输入数字 ");
        return false;
        }
      }
      return true;
    }
    验证邮件格式是否正确
    function isemail(str)
    {
      var bflag=true
        
      if (str.indexOf("'")!=-1) {
        bflag=false
      }
      if (str.indexOf("@")==-1) {
        bflag=false
      }
      else if(str.charAt(0)=="@"){
          bflag=false
      }
      return bflag
    }
      

  2.   

    javascript:
    数字:
    <script language="JavaScript">
    <!--
    function checkdata() 
    {
      if( form1.unitPrice.value !="" && isNaN(form1.unitPrice.value)) 
      {
        alert("\请输入数字 !!");
        document.form1.unitPrice.focus(this);
        document.form1.unitPrice.select(this);
        return false;
      }
      return true;
    }检查email:
    function checkdata() 
    {
      if ( form1.email.value!="" && ( form1.email.value.indexOf('@',0)==-1 || form1.email.value.indexOf('.',0)==-1 || form1.email.value.length<6 ) )
      {
         alert("\请正确输入email !!");
         document.form1.email.focus(this);
         document.form1.email.select(this);
         return false;
       }
    }