<input
 onkeypress="return event.keyCode>=48&&event.keyCode<=57||event.keyCode==46"
 onpaste="return !clipboardData.getData('text').match(/\D/)"
 ondragenter="return false"
 style="ime-mode:Disabled"
>

解决方案 »

  1.   

    用 IsNumeric(表达式) 函数判断是否为数字
    if IsNumeric(表达式) then
        ......
    else
        ......
    end if
      

  2.   

    for (int i=0;i<TextBox.length;i++)
    {
         string a=TextBox.substring(i,1);
         if (TextBox.text>="0" && TextBox.text<="9") 
            {}
         else
            {
              window.alert("...");
              }
    }
      

  3.   

    强列同意 xinyunyishui(心云意水)
      

  4.   

    只能是数字<input onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"><br>