按钮单击我的Android应用程序使用Sencha Touch 2在Android 2.3模拟器中工作正常但在Android 3.0及更高版本中无法正常工作

时间:2012-07-19 12:42:06

标签: android sencha-touch

按钮点击我的Android应用程序使用Sencha Touch 2在Android 2.3模拟器中正常工作但在Android 3.0及更高版本中无法正常工作。当我在Android 3.0及更高版本中运行此应用程序并单击“保存”按钮时,它不会t编译自var isValid = true;线。我的代码如下: -

{
            xtype: 'button',
            text: 'Save',
         handler: function(){
         //var val3 = Ext.ComponentQuery.query('#na')[0].getValue(); 
         val3 = Ext.getCmp('na').getValue();
         console.log(val3);
         val = Ext.getCmp('ea').getValue();          
         console.log(val);
         val4 = val.indexOf("@");
         console.log(val4);
         val5 = val.lastIndexOf(".");
         console.log(val5);
         val2 = Ext.getCmp('pa').getValue();
         console.log(val2); 
         val1 = Ext.getCmp('ra').getValue();    
         console.log(val1); 
            var isValid = true;
            Ext.Msg.alert("Info", "123");
            var errors = new Array();
            Ext.Msg.alert("Info", "456");
           //validate the name                        
            if (val3.search(/[0-9]/) > -1) {
            Ext.Msg.alert("Info", "789");
              isValid = false;
              errors.push({field : 'name',
              reason : 'Name must not contain numbers'});
                }
             if (val3.length <= 0) {

              isValid = false;
              errors.push({field : 'name',
              reason : 'Name should not be blank'});
                }

                if (val3.search(/[@]/) > -1) {
              isValid = false;
              errors.push({field : 'name',
              reason : 'Name must not contain special characters'});
                }
             //validate e-mail                        
              if (val4<1 || val5<val4+2 || val5+2>=val.length)
             {
             isValid = false;
                errors.push({field : 'email',
                reason : 'Invalid email id'});
             }
            if (val.search("/^([a-zA-Z0-9_\.\-])+(@[a-z])+([.][a-z])+$+") > -1){
                isValid = false;
                errors.push({field : 'email',
                reason : 'Invalid Email address'});
              }
            if (val.length <= 0){
                isValid = false;
                errors.push({field : 'email',
                reason : 'Email address should not be blank'});
              }                   
            //validate Password                        
            if (val1 != val2) {
                isValid = false;
                errors.push({field : 'reenter',
                reason : 'Password do not match'});
                 } 
            if(val2 <= 0){
               isValid = false;
               errors.push({field : 'password',
               reason : 'Password should not be blank'});
                 }  
            if(val1 <= 0){
               isValid = false;
               errors.push({field : 'reenter',
               reason : 'Re-enter Password should not be blank'});
                 }  
            if(val1.length > 4){
               isValid = false;
               errors.push({field : 'reenter',
               reason : 'Re-enter Password should not be more than 4 characters'});
               }  
            if(val2.length > 4){
               isValid = false;
               errors.push({field : 'password',
               reason : 'Password should not be more than 4 characters'});
              }  
            //show error if the validation failed                        
            if (!isValid) {
               var errStr = "";
               Ext.each(errors, function(error, index){
               errStr += "[" + (index+1) + "] - " + error.reason + "\n";
               });
               Ext.Msg.alert("Error", errStr);
              } else {//form is valid
                //form.submit();
                Ext.Msg.alert("Info", "Success");
               }
             }

1 个答案:

答案 0 :(得分:0)

我不想成为向你发消息的人,但Sencha Touch 2不支持Android 3.x.只有2.x和4.x.可在此处找到快速的论坛讨论:

http://www.sencha.com/forum/showthread.php?186178-Phonegap-1.5-Sencha-Touch-2-has-problems-on-android-3.0

你的语法看起来很好。