<input type = "text" onchange="test()" id = "a">function test()
{
   document.Form1.a.focus();
   document.all("a").focus();
}函数中的两句话都没有让文本框过的焦点,为什么?
我想做的是在用户输入数据以后才判断,不想用onblur事件!高手指教!

解决方案 »

  1.   

    可以在onblur或者提交数据时判断
      

  2.   

    <input type = "text" onchange="if(...)alert('asdf');" id = "a">
      

  3.   

    <input type = "text" onKeyPress="test()" id = "a">function test()
    {
       document.Form1.a.focus();
       document.all("a").focus();
    }
      

  4.   

    onKeyPress= "return regInput(this,/^[0-9]*$/, String.fromCharCode(event.keyCode))" onpaste= "return regInput(this,/^[0-9]*$/, window.clipboardData.getData('Text'))" ondrop= "return regInput(this,/^[0-9]*$/,event.dataTransfer.getData('Text'))"
    这三个事件都是为了保证广西框里输入的都是数字,事件给你了,楼主可以适当的根据需求改一下。