I have an ajax function that checks fields to validate and display error
messages.
There are multiple messages depending on the error per field in some cases,
to short, to long, already taken, invalid, cant be empty and so on....you
get the idea.
My function is like this:
function(error) {
if(error.length != 0) {
if ( $('#' + fieldName + '-exists').length == 0 )
{
$('#' + fieldName).after('<div class="error-message" id="'+
fieldName +'-exists">' + error + '</div>');
}
}
else {
$('#' + fieldName + '-exists').remove();
}
});
But the error never changes once 1 is called so if to short it says too
short....fix the problem and it only shows too short never any other
message. How can i remove the message if its fixed but still return
anothererror if it exists?
I tried if ( $('#' + fieldName + '-exists').length != error )
so if the error is different display the error but it doesnot remove the
original error....
Ideas?
Thanks
Dave