Ext3.0很实用的2个小插件

Ext新加入了2个很实用的小插件:
1、用来判断时间输入(结束时间不能大于开始时间)。
2、密码验证。


扩展VTypes:

Ext.apply (Ext.form.VTypes, {
daterange : function(val, field) {
var date = field.parseDate (val);

if(!date) {
return;
}
if(field.startDateField && (!this.dateRangeMax || (date.getTime () != this.dateRangeMax.getTime ()))) {
var start = Ext.getCmp (field.startDateField);
start.setMaxValue (date);
start.validate ();
this.dateRangeMax = date;
} else if(field.endDateField && (!this.dateRangeMin || (date.getTime () != this.dateRangeMin.getTime ()))) {
var end = Ext.getCmp (field.endDateField);
end.setMinValue (date);
end.validate ();
this.dateRangeMin = date;
}

/*
* Always return true since we're only using this vtype to set the
* min/max allowed values (these are tested for after the vtype test)
*/
return true;
},
password : function(val, field) {
if(field.initialPassField) {
var pwd = Ext.getCmp (field.initialPassField);
return (val == pwd.getValue ());
}
return true;
},
passwordText : 'Passwords do not match'
});


使用code:

var dr = new Ext.FormPanel({
labelWidth: 125,
frame: true,
title: 'Date Range',
bodyStyle: 'padding:5px 5px 0',
width: 350,
defaults: {
width: 175
},
defaultType: 'datefield',
items: [{
fieldLabel: 'Start Date',
id: 'startdt',
format: 'Y-m-d',
vtype: 'daterange',
endDateField: 'enddt' // id of the end date field
}, {
fieldLabel: 'End Date',
id: 'enddt',
format: 'Y-m-d',
vtype: 'daterange',
startDateField: 'startdt' // id of the start date field
}]
});

dr.render('dr');

var pwd = new Ext.FormPanel({
labelWidth: 125,
frame: true,
title: 'Password Verification',
bodyStyle: 'padding:5px 5px 0',
width: 350,
defaults: {
width: 175,
inputType: 'password'
},
defaultType: 'textfield',
items: [{
fieldLabel: 'Password',
id: 'pass'
}, {
fieldLabel: 'Confirm Password',
vtype: 'password',
initialPassField: 'pass' // id of the initial password field
}]
});

pwd.render('pw');
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值