livevalidation.js custom username check function-Collection of common programming errors
i am having the same issue. Ive found the following, http://forum.jquery.com/topic/ajax-return-value-on-success-or-error-with-livevalidation but have not been able to get it working. BUT YES! At this very moment i made som (crappy) javascript addon that made it behave, i think 🙂
This is what i use.
function check_avail(name, id, postUrl) { var dataVal = name+'='+$(id).val(); var isaccepted = '' $(id).next('div').remove(); $(id).after("
Undersøger om "+name+" er ledigt");
$.ajax({
url: postUrl,
cache: false,
type: 'post',
dataType: 'json',
data: dataVal,
async: false,
success: function(data) {
if( data.success == 'true' )
{
$('#'+name+'-availability').remove();
//return false;
isaccepted = false;
}
if( data.success == 'false' )
{
$('#'+name+'-availability').remove();
// name.destroy();
isaccepted = true;
}
}
});
if (isaccepted == false) {
return false;
} else{
return true
};
}
And
f1.add( Validate.Custom, { against: function() {
return check_avail( 'brugernavn', '#ft001', 'usernamecheck.asp' );
}, failureMessage: 'Brugernavnet er optaget' } );
Hope it helps you 🙂 The json query you can read about on the link in the begining 🙂 (I am not at all skilled at javascript, and the “isaccepted” solution could problalby be made a lot better)
Originally posted 2013-11-13 09:49:17.