Extjs表单默认提交方式提交不了,没有反应
js代码-----------------Ext.onReady(function(){Ext.QuickTips.init();Ext.get("loginpanel"...
js代码-----------------
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.get("loginpanel").setStyle('position','absolute').center(Ext.getBody());
var form=new Ext.form.FormPanel({
renderTo:"myform",
width:600,
defaultType:"textfield",
labelAlign:"right",
waitMsgTarget:true,
renderTo:"loginpanel",
defaults:{border:false,allowBlank:false,blankText:'该字段不允许为空',msgTarget:"side"},
items:[
{fieldLabel:"登录帐号",name:"username",regex:/^[a-zA-Z]{2,6}$/,regexText:"只能是两位到六位的小写字母"},
{fieldLabel:"登录密码",name:"password",inputType:"password",regex:/^.{4,}$/,regexText:"长度不能少于4位"}
],
buttons:[
{
text:"登陆",
handler:function(){
if(form.getForm().isValid()){
this.disabled=true;
form.getForm().doAction("submit",{
url:"login.jsp",
method:"POST",
waitMsg:"正在登录,请稍等...",
success:function(f,a){
alert(a.response.responseText);
},
failure:function(f,a){
alter(a.result.errormsg);
}
});
this.disabled=false;
}
}
},
{text:"取消",handler:function(){form.getForm().reset();}}
]
});
});
jsp代码----------------
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
if("admin".equals(username)&&"123456".equals(password)){
out.println("{success:true,url:\"index.jsp\"}");
}else{
out.println("success:false,errors:[");
if(!"admin".equals(username))
out.println("{id:\"username\",msg:\"用户名错误\"},");
if(!"123456".equals(password))
out.println("{id:\"password\",msg:\"密码错误\"}");
out.println("]}");
}
out.println(username+","+password);
%> 展开
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.get("loginpanel").setStyle('position','absolute').center(Ext.getBody());
var form=new Ext.form.FormPanel({
renderTo:"myform",
width:600,
defaultType:"textfield",
labelAlign:"right",
waitMsgTarget:true,
renderTo:"loginpanel",
defaults:{border:false,allowBlank:false,blankText:'该字段不允许为空',msgTarget:"side"},
items:[
{fieldLabel:"登录帐号",name:"username",regex:/^[a-zA-Z]{2,6}$/,regexText:"只能是两位到六位的小写字母"},
{fieldLabel:"登录密码",name:"password",inputType:"password",regex:/^.{4,}$/,regexText:"长度不能少于4位"}
],
buttons:[
{
text:"登陆",
handler:function(){
if(form.getForm().isValid()){
this.disabled=true;
form.getForm().doAction("submit",{
url:"login.jsp",
method:"POST",
waitMsg:"正在登录,请稍等...",
success:function(f,a){
alert(a.response.responseText);
},
failure:function(f,a){
alter(a.result.errormsg);
}
});
this.disabled=false;
}
}
},
{text:"取消",handler:function(){form.getForm().reset();}}
]
});
});
jsp代码----------------
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
if("admin".equals(username)&&"123456".equals(password)){
out.println("{success:true,url:\"index.jsp\"}");
}else{
out.println("success:false,errors:[");
if(!"admin".equals(username))
out.println("{id:\"username\",msg:\"用户名错误\"},");
if(!"123456".equals(password))
out.println("{id:\"password\",msg:\"密码错误\"}");
out.println("]}");
}
out.println(username+","+password);
%> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询