1、对话框的种类:

a、prompt:弹出一个要求用户输入的对话框

b、alert:警告框

c、wait:为一个进度条

实例:

Ext.Msg.prompt('Milton', 'Where is it?', function(btn,txt)

{ if (txt.toLowerCase() == 'the office') {

Ext.get('my_id').dom.innerHTML = 'Dull Work';

}else{

Ext.get('my_id').dom.innerHTML = txt;

}

Ext.DomHelper.applyStyles('my_id',{

background: 'transparent

url(images/stapler.png) 50% 50% no-repeat'

});

});

说明:上面的Ext.get('my_id')是要获得DOM里面ID号为my_id的元素,然后就可以在这里进行操作,下面的Ext.getBody()也是获得DOM里面的Body元素。

b、

Ext.Msg.alert('Milton',

'Im going to burn the building down!',

function() {

Ext.DomHelper.applyStyles('my_id',{

'background': 'transparent

url(images/fire.png) 0 100% repeat-x'

});

Ext.DomHelper.applyStyles(Ext.getBody(),{

'background-color': '#FF0000'

});

Ext.getBody().highlight('FFCC00',{

endColor:'FF0000',

duration: 6

});

});

2、EXT-JS中自己定义验证方式:

验证方式一般是以vtype定义,所以我们要定义验证方式就要定义Vtype,每个定义都有一个value、mask、error text/和一个function used for testing:

xxxVal: This is the regular expression to match against

xxxMask: This is the masking to restrict user input

xxxText:This is the error message that is displayed

实例:

Ext.form.VTypes['nameVal'] = /^[A-Z][A-Za-z\-]+

[A-Z][A-Za-z\-]+$/;

Ext.form.VTypes['nameMask'] = /[A-Za-z\- ]/;

Ext.form.VTypes['nameText'] = '不允许的排列方式 for Name.';

Ext.form.VTypes['name'] = function(v){

return Ext.form.VTypes['nameVal'].test(v);

posted on 2009-05-22 15:28  wocean  阅读(600)  评论(0编辑  收藏  举报