第一個是作爲例外。我試圖借用相同的想法顯示錯誤消息當用戶嘗試嘗試使用空值。 我有幾個文本字段,我想要顯示一個錯誤消息,當用戶點擊保存按鈕時,必填字段爲空或在單擊該選項卡上的光標後保持空白 並且不在文本字段中輸入任何內容並轉到下一個文本字段。任何幫助,將不勝感激。錯誤消息不顯示當文本字段爲空,並顯示在懸停在
//First code snippet working propely.
this.nameField = new Ext.form.TextField({
fieldLabel:getMsg('testXml','global.name')
\t \t ,allowBlank:false
\t \t ,cls:'c-form-field-required'
\t \t ,name:'Name' \t \t \t
\t \t ,blankText: testQR.getMsg('testXml','address.nameV')
,maxLength:100
});
\t
this.formPanel = new Ext.form.FormPanel({
labelWidth: 100
,labelPad: 10
,labelAlign: 'right'
,bodyBorder: false
,trackResetOnLoad: true
,cls: 'testQR-form-panel'
,autoScroll: true
,defaults: {
\t width: 200
\t ,msgTarget: 'under'
\t ,emptyClass: 'c-form-empty-field'
\t ,invalidClass: 'c-form-invalid'
\t ,validateOnBlur: true
\t ,validationEvent: 'blur'
}
,items:[
\t this.avKeyField
\t ,this.addrKeyField
\t ,this.nameField
\t ,this.addressCodeField] \t \t
}); \t
/*
Second code snippet is not working as accepted.
But when I click on the text field and leave it blank the border of the text field becomes red,
and when I hover over the text field an error message will pop out. \t */
this.descriptionField = new Ext.form.TextField({
\t fieldLabel: getMsg('testXml', 'description'),
\t allowBlank: false,
\t cls: 'c-form-field-required',
\t name: 'description',
\t blankText: testQR.getMsg('testXml', 'description.required'),
\t maxLength: 50,
\t id:"DescriptionDetails"
});
this.testFormPanel = new Ext.form.FormPanel({
id: 'testItemPanels',
trackResetOnLoad: true
,cls: 'testQR-form-panel'
,autoScroll: true
,defaults: {
msgTarget: 'under'
,emptyClass: 'c-form-empty-field'
,invalidClass: 'c-form-invalid'
,validateOnBlur: true
,validationEvent: 'blur'
},
\t border: false
\t \t ,autoHeight: true
\t \t ,bodyStyle: 'padding:1px 1px 1px 1px'
\t \t ,layout:'table'
\t \t ,layoutConfig:{
\t \t \t columns: 3
\t \t }
\t \t ,defaults: {
\t \t \t labelSeparator: '',
\t \t \t //margins:'0 0 0 5',
\t \t \t style: 'marginRight: 5px;',
\t \t \t labelAlign: 'top',
\t \t \t layout:'form',
\t \t \t border: false,
\t \t \t bodyStyle:'background:transparent'
\t \t },
\t items:
\t [{
\t \t items:[this.nameField]
\t \t },
\t \t {
\t \t items:[this.descriptionField]
\t \t }
\t ]
});
\t \t
我沒有在我的ext js文件中定義的額外驗證函數。 – Veds