Duplicate error message printing if user click button multiple times

Duplicate error message printing if user click button multiple times

i am trying to validate user form input field using jQuery. it is validating correctly but error message showing multiple times if i clicked submit button multiple times.
it has to clear previous message before printing new one.

My JQuery Code is:

  1. $(document).ready(function(){
  2.     $('#createUserForm').unbind('submit').bind('submit', function(){
  3.       var username = $("#userName").val();

  4.       if(username == ""){
  5.         $("#userName").after('<p class="text-danger">Username required ?</p>');
  6.         $("#Username").closest('.form-group').addClass('has-error');
  7.       }else{
  8.         $("#userName").find('.text-danger').remove();
  9.         $("#userName").closest('.form-group').addClass('has-success');
  10.       }
  11.       return false;
  12.     });
  13.   });


output is :