サインアップ フォームでコールバック関数を使用して、ユーザー名の有効性を確認しています。validate[必須,funcCall[username_check]]..
ここにJavaScript関数があります
function username_check(field, rules, i, options) {
var username = $('#username').val();
if (username == "" || username.length < 4) {
return options.allrules.validate2fields.alertText;
} else {
jQuery.ajax( {
type: "POST",
url: "<?php echo site_url('signup/validate');?>",
data: 'username=' + username,
cache: false,
success: function (response) {
if (response == 1) {
return options.allrules.validate2fields.alertText;
} else {
return options.allrules.validate2fields.alertError;
}
}
});
}
}
$(document).ready(function(){
$("#signup").validationEngine();
});
検証中、alertText は表示されません。$.ajax プロンプトの外に以下の ifelse 条件を書くと、プロンプトが表示されます
if (response == 1) {
return options.allrules.validate2fields.alertText;
} else {
return options.allrules.validate2fields.alertError;
}
これはバグですか、それとも何か間違っていますか。