title: How to validate multidimensional arrays with Codeigniter and Jquery
body: <p>Hi I need to validate a multidimensional form like this</p>
  
  <pre><code>&lt;input type="text" class="input-xlarge span5 req" id="contact_first_name" name="hotel[&lt;?=$id?&gt;][contact_first_name]" value="&lt;?= set_value('hotel[contact_first_name]') ?&gt;"&gt;
  &lt;input type="text" class="input-xlarge span5 req" id="contact_last_name" name="hotel[&lt;?=$id?&gt;][contact_last_name]" value="&lt;?= set_value('hotel[contact_last_name]') ?&gt;"&gt;
  </code></pre>
  
  <p>I don't know the dimensions of the final array because the inputs are added dynamically via jquery.</p>
  
  <p>I'm using Codeigniter Form_Validation for the server-side and via JQuery with the JQuery Validator for the client-side.</p>
  
  <p>This is my form_validation rules   </p>
  
  <pre><code>$config['add_hotel'] = array(
  array(
      'field' =&gt; 'hotel[][hotel_name]', 
      'label' =&gt; 'Hotel Name', 
      'rules' =&gt; 'required'
      ),    
  array(
      'field' =&gt; 'hotel[][contact_first_name]', 
      'label' =&gt; 'First Name', 
      'rules' =&gt; 'trim|required'
      ),
  array(
      'field' =&gt; 'hotel[][contact_last_name]', 
      'label' =&gt; 'Last Name', 
      'rules' =&gt; 'trim|required'
      ),
  </code></pre>
  
  <p>and this is how i'm doing it via jquery validator</p>
  
  <pre><code>$("#add_hotel").validate({
  rules: {
      "hotel[][hotel_name]": "required"
  
    /*  errorElement: "div",
      wrapper: "div"*/
  },
  messages: {
     "hotel[][hotel_name]": "Please enter the Association Name"
  },
  submitHandler: function(form) {
      form.submit();
  }
  </code></pre>
  
  <p>Don't know how to validate each <code>Hotel[]</code> input with its own id, or maybe there is another way to defining the inputs that can be simpler.</p>