Extjs4.2密码框两次判断和日期判断

来源:互联网 发布:人才招聘源码 码农网 编辑:程序博客网 时间:2024/06/04 19:28
Ext.require([    'Ext.form.*']);Ext.onReady(function() {    // Add the additional 'advanced' VTypes    Ext.apply(Ext.form.field.VTypes, {     //日期范围验证        daterange: function(val, field) {            var date = field.parseDate(val);            if (!date) {                return false;            }            if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {                var start = field.up('form').down('#' + field.startDateField);                start.setMaxValue(date);                start.validate();                this.dateRangeMax = date;            }            else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {                var end = field.up('form').down('#' + 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;        },        //出错时的提示信息        daterangeText: '开始时间必须小于结束时间!',        //密码校验函数        password: function(val, field) {            if (field.initialPassField) {                var pwd = field.up('form').down('#' + field.initialPassField);                return (val == pwd.getValue());            }            return true;        },//出错时的提示信息        passwordText: '密码不匹配!'    });    /*     * ================  Date Range  =======================     */    var dr = Ext.create('Ext.FormPanel', {        renderTo: 'dr',        frame: true,        title: '时间范围',        bodyPadding: '5px 5px 0',        width: 350,        fieldDefaults: {            labelWidth: 125,            msgTarget: 'side',            autoFitErrors: false        },        defaults: {            width: 300        },        defaultType: 'datefield',        items: [            {                fieldLabel: '开始时间',                name: 'startdt',                id: 'startdt',                vtype: 'daterange',                endDateField: 'enddt' // id of the end date field            },            {                fieldLabel: '结束时间',                name: 'enddt',                id: 'enddt',                vtype: 'daterange',                startDateField: 'startdt' // id of the start date field            }        ]    });    /*     * ================  Password Verification =======================     */    var pwd = Ext.create('Ext.FormPanel', {        renderTo: 'pw',        frame: true,        title: '密码验证',        bodyPadding: '5px 5px 0',        width: 350,        fieldDefaults: {            labelWidth: 125,            msgTarget: 'side',            autoFitErrors: false        },        defaults: {            width: 300,            inputType: 'password'        },        defaultType: 'textfield',        items: [            {                fieldLabel: '密码',                name: 'pass',                id: 'pass'            },            {                fieldLabel: '确认密码',                name: 'pass-cfrm',                vtype: 'password',                initialPassField: 'pass' // id of the initial password field            }        ]    });});
0 0
原创粉丝点击