Extjs 验证使用

阅读更多

/**
 * 用户表单面板
 */
Ext.define('user.view.UserFormPanel', {
    extend      : 'Ext.form.Panel',
    requires	: [	'user.store.User',
       				'Ext.ux.TreePicker'
    			],
    alias       : 'widget.UserFormPanel',
    bodyStyle   : 'padding: 10px; background-color: #DCE5F0; border-left: none;',
    defaultType : 'textfield',
    defaults    : {
        labelWidth : 70
    },
    initComponent : function() {
    	this.initValidator();
        this.items = this.buildItems();
        this.callParent();
    },
    initValidator : function() {
    	Ext.apply(Ext.form.VTypes, {
                VTAccount: function(v) {
                    return /^[a-zA-Z]([\w\d]){4,15}$/.test(v);
                },
                VTAccountText: "必须为5-16位字母数字和下划线组成",
                VTAccountMask: /[\w\d]/i,
                
                VTUserName: function(v){
                	return /^([\u4e00-\u9fa5\w\d]){2,15}$/.test(v);
                },
                VTUserNameText:"用户姓名验证"
               
        });
    },
    buildItems : function() {
        return [
        	{
                fieldLabel : '编号',
                name       : 'user.id',
                readOnly	   : true
            },
            {
                fieldLabel : '登录名',
                name       : 'user.account',
                vtype :'VTAccount'
            },
            {
                fieldLabel : '姓名',
                name       : 'userName',
				vtype : 'VTUserName'
            },
            {
                fieldLabel : '注册时间',
                name       : 'user.regTime',
                readOnly	: 'true'
                
            }
        ];
    }
});
 

你可能感兴趣的:(Extjs 验证使用)