新人求教ExtJSform表单问题

黑黢黢 2017-03-09 04:57:57
总是提示我username未定义,哪位大神帮帮忙啊~~~
Ext.onReady(function(){
var formPanel=new Ext.form.FormPanel({
title:'LOGIN',
id:'elId',
autoHeight:true,
x:200,
y:200,
width:300,
renderTo:Ext.getBody(),
frame:true,
cls:'text-align:center',
labelAlign:'center',
items:[{
xtype:'textfield',
name:'username',
fieldLabel:'username',
allowBlank:false, //焦点
blankText:'请输入用户名', //检测出错时的消息
msgTarget:'under' //显示错误信息的四个方式:qtip,title,side,under
},{
xtype:'textfield',
name:'password',
fieldLabel:'password',
allowBlank:false,
inputType:'password',
blankText:'密码不能为空',
msgTarget:'under'
}],
buttonAlign:'center',
buttons:[{
xtype:'button',
text:'登陆',
scope:this,
handler:login
},{
xtype:'button',
text:'重置',
scope:this,
handler:reset
}]
});
//判断登陆的方法
function login(){
formPanel.form.submit({
clientValidation:true,
waitMsg:'正在登陆系统--请稍后.......',
url:'user_login.do',//转到后台服务器地址
method:'post',
params:{userVal:username,pasVal:password},//传参的方法!
success:function(form,action){
Ext.Msg.alert('提示','登陆成功!');
},
failure:function(form,action){
Ext.Msg.alert('提示','登陆失败!');
}
});
}
//重置的方法
function reset(){
formPanel.form.reset();
}
});
...全文
127 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
黑黢黢 2017-03-22
  • 打赏
  • 举报
回复
使用form.getForm().findField("username").getValue()取到值,赋值给userVal。

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧