ExtJS 验证

 

var  registerForm = new Ext.form.FormPanel  
  ({  
    frame : true,  
    title : '注册新用户',  
    labelSeparator : ':',  
    labelWidth : 150,  
    width : 200,  
    height : 600,  
    waitMsgTarget: true, /*  true的意思是说表单提交时的等待信息在这个表单之内显示,而不是弹出框 */ 
    items : [  
    {  
        xtype : "textfield",  
        name : 'UserName',  
        id: 'UserName',  
        allowBlank : false,  
        blankText : '注册用户名不能为空',  
        regex : /^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){5,11}$/,  
        regexText : '用户名不合法(必须以字母开头,长度6-12位)!',//验证错误之后的提示信息  
        fieldLabel : '登录名',  
        emptyText : '填写用户名',  
        invalidText : '用户名已经被注册!',  
        width : 250,  
        validationEvent : 'blur',  
        validator : function(thisText) {  
              var res  
              Ext.Ajax.request  
                ({  
                    url : '/portal/Member.do?method=ajaxCheckUserName&UserName='+thisText,  
                    method : 'post',  
                    success : function(response,options)  
                    {  
                  var res = Ext.util.JSON.decode(response.responseText);  
                  if(res.success == true)  
                  {     
                           
                          isok=true;  
                  }  
                  else 
                  {   
                          isok=false;  
                  }  
                 
                  }  
                });  
           
       
            return isok;  
        }  
    },  
    {  
        xtype : "textfield",  
        name : 'PassWord',  
        id : 'PassWord',  
        width : 250,  
        fieldLabel : '输入登录密码',  
        allowBlank : false,  
        inputType : 'password',  
        emptyText : '填写登录密码',  
        blankText : '登录密码不能为空' 
 
    },  
    {  
        xtype : "textfield",  
        name : 'RePassWord',  
        id : 'RePassWord',  
        width : 250,  
        allowBlank : false,  
        fieldLabel : '再次输入密码',  
        emptyText : '填写重复密码',  
        blankText : '重复密码不能为空',  
        vtype : 'password',  
        inputType : 'password',  
        initialPassField : 'PassWord' 
    }, new Ext.form.ComboBox({  
                id : 'Question',  
                name : 'Question',  
                fieldLabel : '请选择密码问题',  
                triggerAction : 'all',  
                editable : false,  
                store : questionstore,  
                emptyText : '请选择',  
                displayField : 'qu',  
                valueField : 'qu',  
                mode : 'local',  
                anchor : '40%',  
                allowBlank : false,  
                blankText : '密码问题不能为空',  
                forceSelection : true,  
                resizable : true,  
                typeAhead : true 
            }),  
 
    {  
        xtype : "textfield",  
        id:  'Answer',  
        name : 'Answer',  
        fieldLabel : '请输入密码问题答案',  
        width : 250,  
        emptyText : '密码问题答案',  
        allowBlank : false,  
        blankText : '密码问题答案不能为空' 
 
    },  
 
    new Ext.form.ComboBox({  
                id : 'RoleType',  
                name : 'RoleType',  
                displayField : 'roleType',  
                fieldLabel : '用户类型',  
                triggerAction : 'all',  
                valueField : 'value',  
                mode: 'local',  
                editable : false,  
                emptyText : '请选择',  
                mode : 'local',  
                anchor : '60%',  
                store : roleTypeStore,  
                allowBlank : false,  
                blankText : '用户类型不能为空',  
                forceSelection : true,  
                resizable : true,  
                typeAhead : true,  
                listeners : {  
                    select : function(form, record, index) {  
                        var store;  
                        getId=record.get('value');  
                        if (record.get('value') == 'f') {  
                            store = familyStore;  
                        } else if (record.get('value') == 'u') {  
                            store = unitStore;  
 
                        } else if (record.get('value') == 'e') {  
                            store = expertStore;  
 
                        } else if (record.get('value') == 'c') {  
                            store = consumerStore;  
 
                        } else if (record.get('value') == 's') {  
                            store = stuffStore;  
 
                        }  
                        registerForm.getForm().findField('AccountType')  
                                .clearValue();  
                        registerForm.getForm().findField('AccountType').store = store;  
 
                        if (registerForm.getForm().findField('AccountType').view) {  
                            registerForm.getForm().findField('AccountType').view  
                                    .setStore(store);  
                        }  
                        registerForm.getForm().findField('AccountType')  
                                .enable();  
 
                    }  
                }  
            }),  
 
    new Ext.form.ComboBox({  
                id : 'AccountType',  
                name : 'AccountType',  
                displayField : 'accountType',  
                valueField : 'value',  
                name : 'AccountType',  
                fieldLabel : '帐户类型',  
                triggerAction : 'all',  
                editable : false,  
                emptyText : '请选择',  
                mode : 'local',  
                anchor : '80%',  
                allowBlank : false,  
                blankText : '密码问题不能为空',  
                forceSelection : true,  
                resizable : true,  
                typeAhead : true 
            }),  
      new Ext.form.TextArea({  
                name : 'Summary',  
                id : 'Summary',  
                fieldLabel : '概述或欢迎辞',  
                width : 300  
            }),  
    {  
        xtype : "textfield",  
        id : 'Email',  
        name : 'Email',  
        fieldLabel : 'E-mail',  
        emptyText : '请输入E-mail(电子邮箱)',  
        allowBlank : false,  
        width : 250,  
        blankText : 'E-mail(电子邮箱)不能为空',  
        regex : /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/,  
        regexText : '电子邮件格式错误!'//验证错误之后的提示信息  
    }, {  
        xtype : "textfield",  
        id : 'Mobile',  
        name : 'Mobile',  
        fieldLabel : '移动电话',  
        width : 250,  
        regex : /^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/,  
        regexText : '移动电话号码格式输入错误!' 
 
    }, {  
        xtype : "textfield",  
        id : 'Telephone',  
        name : 'Telephone',  
        fieldLabel : '电话号码',  
        width : 250,  
        regex : /^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/,  
        regexText : '电话号码格式输入错误!' 
    }],  
    buttons : [{  
                text : '注册',  
                handler : registerSubmit  
            }]  
           
   
           
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值