给TextBox加一个OnTextChanged属性阿!然后用js写,很简单嘛!
<script>
funtion Changed(obj)
{
  str = document.form1.TextBox1.Text.Trim();      
   if(str = "")
  {
     window.alert('不能为空!');
  }
  for (nIndex=0; nIndex<str.length; nIndex++)      
   {      
 cCheck = str.charAt(nIndex);      
 if (!IsDigit(cCheck))      
 {      
   alert("只能使用数字");      
   return false;      
 }      
  }  }
function IsDigit(cCheck)      
{      
    return (('0'<=cCheck) && (cCheck<='9'));      

</script>