Ajax validation issue with array

Ajax validation issue with array

I am trying to validate my codeigniter based from using jquery ajax.  in my form i have dynamic fields which generates fields name like fault[0],fault[1],fault[2]......  this jquery script i am using works only  the ID attribute & NAME attribute of a field are same. since array fields have [] marks i am unable to validate them. 

i need to know a way doing this without id & same name rule. 

i think this part manages the validate the fields only with same name & id.

  1.  
  2. $.each(response.messages, function(key, value) {
  3.             var element = $('#' + key);
  4.             

this is my full script

  1. $('#form-user').submit(function(e) {
  2.     e.preventDefault();

  3.     var me = $(this);

  4.     // perform ajax
  5.     $.ajax({
  6.       url: me.attr('action'),
  7.       type: 'post',
  8.       data: me.serialize(),
  9.       dataType: 'json',
  10.       success: function(response) {
  11.         if (response.success == true) {
  12.           // if success we would show message
  13.           // and also remove the error class
  14.           $('#the-message').append('<div class="alert alert-success">' +
  15.             '<span class="glyphicon glyphicon-ok"></span>' +
  16.             ' Data has been saved' +
  17.             '</div>');
  18.           $('.form-group').removeClass('has-error')
  19.                   .removeClass('has-success');
  20.           $('.text-danger').remove();

  21.           // reset the form
  22.           me[0].reset();

  23.           // close the message after seconds
  24.           $('.alert-success').delay(500).show(10, function() {
  25.             $(this).delay(3000).hide(10, function() {
  26.               $(this).remove();
  27.             });
  28.           })
  29.         }
  30.         else {
  31.           $.each(response.messages, function(key, value) {
  32.             var element = $('#' + key);
  33.             
  34.             element.closest('div.form-group')
  35.             .removeClass('has-error')
  36.             .addClass(value.length > 0 ? 'has-error' : 'has-success')
  37.             .find('.text-danger')
  38.             .remove();
  39.             
  40.             element.after(value);
  41.           });
  42.         }
  43.       }
  44.     });
  45.   });