<script language="javascript">
Ext.onReady(function(){
   Ext.form.Field.prototype.msgTarget = 'side';//定义表单
var simple = new Ext.FormPanel({
labelWidth: 75, 
baseCls: 'x-plain',
width: 150,
defaultType: 'textfield',//默认字段类型//定义表单元素
items: [{
fieldLabel: '帐户',
name: 'name',//元素名称
//anchor:'95%',//也可用此定义自适应宽度
allowBlank:false,//不允许为空
blankText:'帐户不能为空'//错误提示内容
},{
inputType:'password',
fieldLabel: '密码',
//anchor:'95%',
name: 'pws',
allowBlank:false,
blankText:'密码不能为空'
}
],buttons: [{
text: '登陆',
type: 'submit',
//定义表单提交事件
handler:function(){
if(simple.form.isValid()){//验证合法后使用加载进度条
Ext.MessageBox.show({
title: '请稍等',
msg: '正在加载...',
progressText: '',
width:300,
progress:true,
closable:false,
animEl: 'loding'
});
//控制进度速度
var f = function(v){
return function(){
var i = v/11;
Ext.MessageBox.updateProgress(i, '');
};
};for(var i = 1; i < 13; i++){
setTimeout(f(i), i*150);
}//提交到服务器操作
simple.form.doAction('submit',{
url:'check.php',//文件路径
method:'post',//提交方法post或get
params:'',
//提交成功的回调函数
success:function(form,action){
if (action.result.msg=='ok') {
document.location='index.html';
} else {
Ext.Msg.alert('登陆错误',action.result.msg);
}
},
//提交失败的回调函数
failure:function(){
Ext.Msg.alert('错误','服务器出现错误请稍后再试!');
}
});

}
},{
text: '取消',
handler:function(){simple.form.reset();}//重置表单
}]
}); 
//定义窗体
var win = new Ext.Window({
id:'win',
title:'用户登陆',
layout:'fit', //之前提到的布局方式fit,自适应布局 
width:300,
height:150,
plain:true,
bodyStyle:'padding:5px;',
maximizable:false,//禁止最大化
closeAction:'close',
closable:false,//禁止关闭
collapsible:true,//可折叠
plain: true,
buttonAlign:'center',
items:simple//将表单作为窗体元素嵌套布局
});
win.show();//显示窗体
});
</script> 
这是我的一段登陆的代码

解决方案 »

  1.   

    onerror=handleErr
    var txt=""

    function handleErr(msg,url,l)
    {
    txt="There was an error on this page.\n\n"
    txt+="Error: " + msg + "\n"
    txt+="URL: " + url + "\n"
    txt+="Line: " + l + "\n\n"
    txt+="Click OK to continue.\n\n"
    alert(txt)
    return true
    }
    这是一个错误处理的函数,希望你放到前面,如果说给你检查错误,我想,应该自己去好好的查查是哪里有问题,可以推荐用aptana,
    这是一个比较好的js软件吧,而且十分易用.推荐看看,
      

  2.   

    请问sy_binbin 登录时提交到check.php页面,是否登录成功的返回值是怎么获取的啊?
    //提交到服务器操作
    simple.form.doAction('submit',{
    url:'check.php',//文件路径
    method:'post',//提交方法post或get
    params:'',
    //提交成功的回调函数
    success:function(form,action){
    if (action.result.msg=='ok') {
    document.location='index.html';
    } else {
    Ext.Msg.alert('登陆错误',action.result.msg);
    }
    },
    //提交失败的回调函数
    failure:function(){
    Ext.Msg.alert('错误','服务器出现错误请稍后再试!');
    }
      

  3.   

    还没显示出来啊!6楼中的代码就是我的登录页面中的所有代码啊!帮我看看出现什么问题了啊,我弄了好几天了!
    不知道为什么报Ext.fly(...)为空或不是对象!
      

  4.   

    我建议你的提交用ajaxrequest传递
    然后判断返会值就可以了
      

  5.   

    http://hi.baidu.com/eredlab/blog/item/8395e388144c5492a5c2722e.html
    登录页面在此!
      

  6.   

    <div id="hello-win" class="x-hidden">
        <div class="x-window-header">信息管理系统</div>
        <div id="hello-tabs">
             <img src="images/systemBanner.jpg"/>
        </div>
    <div id='loginInfo' style='color:red;padding-left:120px;'>
    把以上代码加入你的BODY区域
      

  7.   

    <div id="hello-win" class="x-hidden">
        <div class="x-window-header">信息管理系统</div>
        <div id="hello-tabs">
             <img src="images/systemBanner.jpg"/>
        </div>
    <div id='loginInfo' style='color:red;padding-left:120px;'>
    <!-- 预设信息,位入登录面板下面一行 -->
    请输入已经通过审核的用户名与密码进行登陆!
    </div>
    </div>
      

  8.   

    去掉 Ext.QuickTips.init();  这个好像是extjs的一个bug