function myForm_1() {
Ext.QuickTips.init();
var form = new Ext.form.FormPanel({
defaultType : 'textfield',
labelAlign : 'right',
title : 'form',
labelWidth : 50,
frame : true,
width : 220,
items : [new Ext.form.TextField({
name : "userName",
fieldLabel : '文本框',
inputType : "text",
allowBlank : false,
emptyText : "請(qǐng)正確輸入數(shù)據(jù)",
maxLength : 10,
maxLengthText : "請(qǐng)不要超過(guò)10個(gè)字符",
invalidText : "invalidText:只能夠輸入數(shù)字",
regex : /^\d+$/,
regexText : "只能夠輸入數(shù)字",
validationEvent : "click"
// validator:function(){Ext.Msg.alert("提示信息","只能夠輸入數(shù)字");}
})],
buttons : [{
text : '按鈕',
handler : function() {
Ext.Msg.alert("提示信息", "Hello,你好哈.");
}
}]
});
form.render("form");
}
function myForm_2() {
var form1 = new Ext.form.FormPanel({
width : 350,
frame : true,
renderTo : "form1",
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
defaults : {
width : 200,
xtype : "textfield"
},
items : [{
fieldLabel : "UserName",
name : "user",
id : "user"
}, {
fieldLabel : "PassWord",
inputType : "password",
name : "pass",
id : "pass"
}],
buttons : [{
text : "確定"
}, {
text : "取消",
handler : function() {
var svalue = "用戶名:"
+ Ext.get('user').getValue();
svalue += ",密碼:" + Ext.get('pass').getValue();
Ext.Msg.alert("提示信息", svalue);
}
}]
});
}
function myForm_3() {
var form1 = new Ext.form.FormPanel({
width : 850,
frame : true,
renderTo : "form1",
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
defaults : {
width : 200,
xtype : "textfield"
},
items : [{
xtype : "fieldset",
checkboxToggle : true,// 關(guān)鍵參數(shù),其他和以前的一樣
checkboxName : "個(gè)人信息",
title : "選填信息",
defaultType : 'textfield',
width : 830,
autoHeight : true,// 使自適應(yīng)展開排版
items : [{
fieldLabel : "UserName",
name : "user",
anchor : "95%"// 330px-labelWidth剩下的寬度的95%,留下5%作為后面提到的驗(yàn)證錯(cuò)誤提示
}, {
fieldLabel : "PassWord",
inputType : "password",// 密碼文本
name : "pass",
anchor : "95%"
}]
}, {
xtype : 'fieldset',
title : '個(gè)人信息',
collapsible : true,
autoHeight : true,
width : 830,
defaults : {
width : 150
},
defaultType : 'textfield',
items : [{
fieldLabel : '愛(ài)好',
name : 'hobby',
value : 'www.cnblogs.com'
}, {
xtype : "combo",
name : 'sex',
store : ["男", "女", "保密"],
fieldLabel : "性別",
emptyText : '請(qǐng)選擇性別.'
}, {
xtype : "datefield",
fieldLabel : "生日",
anchor : "99%"
}]
}],
buttons : [{
text : "確定"
}, {
text : "取消"
}]
});
}
function myForm_4() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';// 提示的方式,枚舉值為"qtip","title","under","side",id(元素id)
var form1 = new Ext.form.FormPanel({
width : 350,
frame : true,
renderTo : "form1",
labelWidth : 80,
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
defaults : {
width : 150,
xtype : "textfield",
inputType : "password"
},
items : [{
fieldLabel : "不能為空",
allowBlank : false,// false則不能為空,默認(rèn)為true
blankText : "不能為空,請(qǐng)?zhí)顚?/span>",// 錯(cuò)誤提示信息,默認(rèn)為This field is
vtype : "email",// 'email'只能有效的Email,'alpha'只能輸入字母,'alphanum'只能輸入數(shù)字和字母,'url'只能輸入url
vtypeText : "不是有效的郵箱地址",// 錯(cuò)誤提示信息,默認(rèn)值我就不說(shuō)了
id : "blanktest",
anchor : "90%"
}]
});
}
function myForm_5() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';// 提示的方式,枚舉值為"qtip","title","under","side",id(元素id)
// 先用Ext.apply方法添加自定義的password驗(yàn)證函數(shù)(也可以取其他的名字)
Ext.apply(Ext.form.VTypes, {
password : function(val, field) {// val指這里的文本框值,field指這個(gè)文本框組件,大家要明白這個(gè)意思
if (field.confirmTo) {// confirmTo是我們自定義的配置參數(shù),一般用來(lái)保存另外的組件的id值
var pwd = Ext.get(field.confirmTo);// 取得confirmTo的那個(gè)id的值
return (val == pwd.getValue());
}
return true;
}
});
var form1 = new Ext.form.FormPanel({
width : 350,
frame : true,
renderTo : "form1",
labelWidth : 80,
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
defaults : {
width : 150,
xtype : "textfield",
inputType : "password"
},
items : [{
fieldLabel : "密碼",
id : "pass1",
anchor : "90%"
}, {
fieldLabel : "確認(rèn)密碼",
id : "pass2",
vtype : "password",// 自定義的驗(yàn)證類型
vtypeText : "兩次密碼不一致!",
confirmTo : "pass1",// 要比較的另外一個(gè)的組件的id
anchor : "90%"
}]
});
}
function myForm_6() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
var combo = new Ext.form.ComboBox({
store : ['湖北', '江西', '安徽'],
// emptyText : '請(qǐng)選擇一個(gè)省份
.',
applyTo : 'combo'
});
}
function myForm_7() {
var ExtSelect = new Ext.form.ComboBox({
transform : "select",// html中的id
width : 80
// 寬度
});
}
function myForm_8() {
Ext.QuickTips.init();
var myform = new Ext.FormPanel({
frame : true,
width : 600,
layout : "form",
labelWidth : 50,
title : "htmleditor簡(jiǎn)單示例",
labelAlign : "top",// items中的標(biāo)簽的位置
renderTo : Ext.getBody(),
items : [{
xtype : "htmleditor",
id : "he",
fieldLabel : "編輯器",
anchor : "99%"
}]
});
}
Ext.onReady(myForm_8);
Ext.QuickTips.init();
var form = new Ext.form.FormPanel({
defaultType : 'textfield',
labelAlign : 'right',
title : 'form',
labelWidth : 50,
frame : true,
width : 220,
items : [new Ext.form.TextField({
name : "userName",
fieldLabel : '文本框',
inputType : "text",
allowBlank : false,
emptyText : "請(qǐng)正確輸入數(shù)據(jù)",
maxLength : 10,
maxLengthText : "請(qǐng)不要超過(guò)10個(gè)字符",
invalidText : "invalidText:只能夠輸入數(shù)字",
regex : /^\d+$/,
regexText : "只能夠輸入數(shù)字",
validationEvent : "click"
// validator:function(){Ext.Msg.alert("提示信息","只能夠輸入數(shù)字");}
})],
buttons : [{
text : '按鈕',
handler : function() {
Ext.Msg.alert("提示信息", "Hello,你好哈.");
}
}]
});
form.render("form");
}
function myForm_2() {
var form1 = new Ext.form.FormPanel({
width : 350,
frame : true,
renderTo : "form1",
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
defaults : {
width : 200,
xtype : "textfield"
},
items : [{
fieldLabel : "UserName",
name : "user",
id : "user"
}, {
fieldLabel : "PassWord",
inputType : "password",
name : "pass",
id : "pass"
}],
buttons : [{
text : "確定"
}, {
text : "取消",
handler : function() {
var svalue = "用戶名:"
+ Ext.get('user').getValue();
svalue += ",密碼:" + Ext.get('pass').getValue();
Ext.Msg.alert("提示信息", svalue);
}
}]
});
}
function myForm_3() {
var form1 = new Ext.form.FormPanel({
width : 850,
frame : true,
renderTo : "form1",
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
defaults : {
width : 200,
xtype : "textfield"
},
items : [{
xtype : "fieldset",
checkboxToggle : true,// 關(guān)鍵參數(shù),其他和以前的一樣
checkboxName : "個(gè)人信息",
title : "選填信息",
defaultType : 'textfield',
width : 830,
autoHeight : true,// 使自適應(yīng)展開排版
items : [{
fieldLabel : "UserName",
name : "user",
anchor : "95%"// 330px-labelWidth剩下的寬度的95%,留下5%作為后面提到的驗(yàn)證錯(cuò)誤提示
}, {
fieldLabel : "PassWord",
inputType : "password",// 密碼文本
name : "pass",
anchor : "95%"
}]
}, {
xtype : 'fieldset',
title : '個(gè)人信息',
collapsible : true,
autoHeight : true,
width : 830,
defaults : {
width : 150
},
defaultType : 'textfield',
items : [{
fieldLabel : '愛(ài)好',
name : 'hobby',
value : 'www.cnblogs.com'
}, {
xtype : "combo",
name : 'sex',
store : ["男", "女", "保密"],
fieldLabel : "性別",
emptyText : '請(qǐng)選擇性別.'
}, {
xtype : "datefield",
fieldLabel : "生日",
anchor : "99%"
}]
}],
buttons : [{
text : "確定"
}, {
text : "取消"
}]
});
}
function myForm_4() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';// 提示的方式,枚舉值為"qtip","title","under","side",id(元素id)
var form1 = new Ext.form.FormPanel({
width : 350,
frame : true,
renderTo : "form1",
labelWidth : 80,
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
defaults : {
width : 150,
xtype : "textfield",
inputType : "password"
},
items : [{
fieldLabel : "不能為空",
allowBlank : false,// false則不能為空,默認(rèn)為true
blankText : "不能為空,請(qǐng)?zhí)顚?/span>",// 錯(cuò)誤提示信息,默認(rèn)為This field is
vtype : "email",// 'email'只能有效的Email,'alpha'只能輸入字母,'alphanum'只能輸入數(shù)字和字母,'url'只能輸入url
vtypeText : "不是有效的郵箱地址",// 錯(cuò)誤提示信息,默認(rèn)值我就不說(shuō)了
id : "blanktest",
anchor : "90%"
}]
});
}
function myForm_5() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';// 提示的方式,枚舉值為"qtip","title","under","side",id(元素id)
// 先用Ext.apply方法添加自定義的password驗(yàn)證函數(shù)(也可以取其他的名字)
Ext.apply(Ext.form.VTypes, {
password : function(val, field) {// val指這里的文本框值,field指這個(gè)文本框組件,大家要明白這個(gè)意思
if (field.confirmTo) {// confirmTo是我們自定義的配置參數(shù),一般用來(lái)保存另外的組件的id值
var pwd = Ext.get(field.confirmTo);// 取得confirmTo的那個(gè)id的值
return (val == pwd.getValue());
}
return true;
}
});
var form1 = new Ext.form.FormPanel({
width : 350,
frame : true,
renderTo : "form1",
labelWidth : 80,
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
defaults : {
width : 150,
xtype : "textfield",
inputType : "password"
},
items : [{
fieldLabel : "密碼",
id : "pass1",
anchor : "90%"
}, {
fieldLabel : "確認(rèn)密碼",
id : "pass2",
vtype : "password",// 自定義的驗(yàn)證類型
vtypeText : "兩次密碼不一致!",
confirmTo : "pass1",// 要比較的另外一個(gè)的組件的id
anchor : "90%"
}]
});
}
function myForm_6() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
var combo = new Ext.form.ComboBox({
store : ['湖北', '江西', '安徽'],
// emptyText : '請(qǐng)選擇一個(gè)省份

applyTo : 'combo'
});
}
function myForm_7() {
var ExtSelect = new Ext.form.ComboBox({
transform : "select",// html中的id
width : 80
// 寬度
});
}
function myForm_8() {
Ext.QuickTips.init();
var myform = new Ext.FormPanel({
frame : true,
width : 600,
layout : "form",
labelWidth : 50,
title : "htmleditor簡(jiǎn)單示例",
labelAlign : "top",// items中的標(biāo)簽的位置
renderTo : Ext.getBody(),
items : [{
xtype : "htmleditor",
id : "he",
fieldLabel : "編輯器",
anchor : "99%"
}]
});
}
Ext.onReady(myForm_8);