こんにちは、jQuery LiveValidation ライブラリを利用した Ajax Call を使用してフィールドを検証しようとしています。Ajax 呼び出しでは、実際に 2 つのことを確認していますが、いずれかを検証できないと、2 つの異なるメッセージが返されます。さて、私のQnは、サーバーから返されるメッセージでそのfailureMessageを設定する方法です。以下のように私のJSコードID:
var mymsg = "";
function check_avail(id, postUrl,callback)
{
var dataVal = id+'='+$("#"+id).val();
var isaccepted = ''
$('#'+id).next('span').remove();
$("#check-"+id).show();
$.ajax({
url: postUrl,
cache: false,
type: 'post',
dataType: 'json',
data: dataVal,
async: false,
success: function(data) {
$("#check-"+id).hide();
if( data.success === 'true' )
{
isaccepted = true;
}
if( data.success === 'false' )
{
isaccepted = false;
callback(data.message);
}
}
});
if (isaccepted === false) {
$('.grid_16').find('input, textarea, button, select').attr('disabled','disabled');
$('#subs_mob_no').removeAttr('disabled');
return false;
} else{
$('.grid_16').find('input, textarea, button, select').removeAttr('disabled');
return true
};
}
mob_no.add(Validate.Custom, { against: function(value, args) { return check_avail(subs_mob_no', '<?php echo site_url('recycledsafman/ajax_check_avilable'); ?>',function(msg){
mymsg = msg;
});
},failureMessage:this.mymsg} );
どなたか教えていただけませんか?