我有一个form
var AddFormPanel = new Ext.form.FormPanel({
width: 715,
height: 260,
plain: true,
layout: "form",
labelWidth: 75,
cls: 'x-formpanelleft',
labelAlign: "left",
//锚点布局-
defaults: { anchor: "95%", msgTarget: "side" },
buttonAlign: "center",
bodyStyle: "padding:15 5 0 20",
reader: new Ext.data.JsonReader({ root: 'data' },
[{ name: 'formUserName', mapping: 'UserName', type: 'string' },
{ name: 'formEmail', mapping: 'Email', type: 'string' },
{ name: 'cb-Intitution', mapping: 'Institution', type: 'string' },
{ name: 'cb-Order', mapping: 'Order', type: 'string' },
{ name: 'cb-Invoice', mapping: 'Invoice', type: 'string' },
{ name: 'cb-Setting', mapping: 'Setting', type: 'string' },
{ name: 'cb-Manage', mapping: 'Manage', type: 'string' },
{ name: 'ID', mapping: 'ID', type: 'string' }
]),
items: [{
name: "formUserName",
id: 'formUserName',
xtype: "textfield",
fieldLabel: "UserName",
maxLength: 50,
allowBlank: false,
blankText: "不允许为空"
}, {
name: "formPassWord",
id: 'formPassWord',
xtype: "textfield",
fieldLabel: "PassWord",
maxLength: 50
}, {
name: "formEmail",
id: 'formEmail',
xtype: "textfield",
fieldLabel: "Email",
maxLength: 150,
allowBlank: false,
blankText: "不允许为空"
}, {
layout: 'column',
border: false,
// defaults are applied to all child items unless otherwise specified by child item
defaults: {
columnWidth: '.2',
border: false
},
items: individual
}, {
xtype: "hidden",
name: "ID",
id: 'ID'
}]
});
我想在加载数据(也就是edit)的时候,把password设置成可以为空,但在添加的时候把password设置成不可以为空.
就是在
AddFormPanel.form.load({
url: '/Url/Manage/UserEditLoad.aspx?id=' + rows.get('ID'),
waitMsg: '正在载入数据...',
failure: function(form, action) {
Ext.MessageBox.alert('编 辑', '载入失败!');
}
});
的时候把password设置成可以为空
在
tbar: [
new Ext.Toolbar.Fill()
, {
text: "Add",
//默认样式为按下
//pressed:true,
tooltip: "Add",
iconCls: "addicon",
handler: AddDetail
的时候把password设置成不可以为空
在add/edit里面直接修改allowBlank的值
默认为可以为空. 直接由JS验证
在点添加的时候由ID 'formPassWord'获取password值,判断不能为空,alert提示..
在点编辑的时候...就不用判断password了..
最好分开做,好弄一点