如题

解决方案 »

  1.   

    onkeyup="value="/value.replace(/["^0-9|10]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^0-9|10]/g,''))"
      

  2.   

    问题应该是0-9这10个数字吧?
    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar >= (char)48 && e.KeyChar <= (char)57)
                {
                    e.Handled = false;
                }
                else
                {
                    e.Handled = true;
                }         }
      

  3.   

    using System.Runtime.InteropServices;[DllImport("User32.dll")]
    static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    [DllImport("User32.dll")]
    static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    public const int GWL_STYLE = -16;
    public const int ES_NUMBER = 0x2000;
    private void Form1_Load(object sender, EventArgs e)
    {
        SetWindowLong(textBox1.Handle, GWL_STYLE,
            GetWindowLong(textBox1.Handle, GWL_STYLE) | ES_NUMBER);
    }// orprivate void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
        e.Handled = "0123456789".IndexOf(e.KeyChar) < 0;
    }
      

  4.   

    判断是否只含数字
    private bool isNum(string keyChar)
        {
            int i = 0;
            char c;
            for (i = 0; i < keyChar.Length; i++)
            {
                c = keyChar[i];
                if (!(c >= 48 && c <= 57))
                {
                    return false;
                }
            }
            return true;
        }
      

  5.   

    如果是服务器的TEXTBOX控件
     设置maxlenth属性,你的情况是填写10
      

  6.   

    然后写个方法判断char是否为数字,使用system.convert.toint32()方法。如果字符不是数字,返回的好象是0或-1。
    在KeyDown事件带入方法
      

  7.   

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

  8.   

    <input style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9" onKeyPress="if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false">
      

  9.   

    只能输入数字:onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"