Sencha Touch 2 を使用した Android アプリのボタン クリックは、Android 2.3 エミュレーターでは正常に動作しますが、Android 3.0 以降では正しく動作しません。このアプリを Android 3.0 以降で実行し、[保存] ボタンをクリックすると、var isValid からコンパイルされません。 =真; ライン。私のコードは次のとおりです: -
{
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");
}
}