I have this script: $(document).ready( function() { $('#username').blur( function () { fieldName = $(this).attr('id'); fieldValue = $(this).val(); $.post('/users/ajax_validate', { field: fieldName, value: fieldValue }, function(error) { if(error.length != 0) { $('#username').after('<div class="error-message" id="'+ fieldName +'-exists">' + error + '</div>'); } else { $('#' + fieldName + '-exists').remove(); } }); }); }); So when the user leaves the field it checks validation. If error it shows an error message. Everything is working fine except if the user goes back to the field where there was an error and does not chnge anything and leaves the field again the error message is duplicated. So they enter a username peter it says "Please choose a different name" if they go back to the username and thenleavewith out changing "peter" i now have: "Please choose a different name" "Please choose a different name" What do I have to change / add so that only 1 message will appear? Thanks Dave
[jQuery] Validation Error message help
Dave Maharaj :: WidePixels.com Tue, 11 Aug 2009 09:18:08 -0700
- [jQuery] Validation Error message help Dave Maharaj :: WidePixels.com