本节内容:
Extjs4实现的表单登录功能,登录成功跳转页面。
例子:
复制代码 代码示例:
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.create('Ext.form.Panel',{
title:'form2',
width:300,
height:200,
frame:true,
renderTo:'formDemo',
defaultType:'textfield',
defaults:{
allowBlank:false,
labelWidth:60,
width:240,
msgTarget:'side'
},
items:[{
name:'userName',
fieldLabel:'Name'
},
{
name:'password',
fieldLabel:'Pass'
}], // www.jb200.com
buttons:[{
text:'提交',handler:function(){
var basic=this.up('form').getForm();
basic.submit({
url:'/Extjs4/formAction!getForm.action',
method:'POST',
success:function(form,action){
location.href="/Extjs4/demo.html";
},
failure:function(form,action){
var data=action.response.responseText;
var json = eval("("+data+")");
Ext.Msg.alert('提示',json.message);
}
});
}
},
{text:'重置',handler:function(){
this.up('form').getForm().reset();
}
}
]
});
});