Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee 朱秋贵内科诊所 My腾云code

EXJS 表单验证

 Ext.apply(Ext.form.VTypes, {
     //密码   
     repetition: function(val, field) {
          if (field.repetition) {
            var cmp = Ext.getCmp(field.repetition.targetCmpId);
             if (val == cmp.getValue()) {  //取得目标组件(表单)的值,与宿主表单的值进行比较。
                return true;
             } else {
                 return false;
             }
          }
     },
     repetitionText:  '密码不匹配',

 


     //手机或电话
     phonecheck : function(val, field) {
            var str=val;

            //格式:01087654321|010-87654321|(010)87654321|1**********
            var reg=/(^[0-9]{3,4}[0-9]{7,8}$)|(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/; 
            if(!reg.test(str)){return false;}
            return true;
     } ,
     phonecheckText : "电话号码不匹配!"
    
    });

 

 

     var mobile = new Ext.form.TextField({
        fieldLabel :'<span style="color:red;">*</span>'+ '联系电话',
        name : 'mobile',
        allowBlank : false,
        vtype: 'phonecheck',
        maxLength : 18,
        id : 'mobile',
        anchor : '90%'
   });

posted @ 2010-12-14 11:08  cn2024  阅读(250)  评论(0编辑  收藏  举报