1、浏览器加载页面的时候,光标直接会在指定的文本域(如:textfield)。2、页面加载完毕了,开始做验证,当某一项验证不通过时,光标回到此文本域中。  非常感谢!!!

解决方案 »

  1.   

    Ext.getCmp('').focus()
    Ext.get('id').dom.focus()
    document.getElementById('').focus()
    都可以
      

  2.   

    老兄,这几个我试过了,不可以!(感觉好奇怪啊!)//代码
    //在tbar中写一个:textfield
    tbar:[
           new Ext.form.Label({text:'气表编号:'}),
           {
           xtype:'textfield',
           name:'METER_ID',
           id:'METER_ID',
           maxLength:20,
           focus:true
           },
           '-',
    {pressed:true,text:"查找",handler:queryFun}
    ],{pressed:true,text:"查找",handler:queryFun}//点击查询触发:
    function queryFun(){

    //通过id获取控件的值
    if(Ext.getCmp("METER_ID").getValue() == ""){

    Ext.Msg.alert("提示框","请填写气表编号!");
    Ext.getCmp("METER_ID").focus();
    Ext.get("METER_ID").dom.focus();
    document.getElementById("METER_ID").focus();

    }else{

    Ext.Msg.alert("提示框","您填写的气表编号为:"+Ext.getCmp("METER_ID").getValue());
    s();

    }

    }