Search code examples
jqueryjquery-uivalidationcodeigniterjquery-ui-tabs

Implementing Codeigniter validation into jQuery Tabs UI


I'm not sure if its already been done but I am trying to implement Codeigniter validation rules to 'hook' into the jQuery Tabs UI for a backend I'm producing.

Does anyone know if somebody has already achieved this - it would be nice for the form validation to indicate a particular tab has errors on the tab with the form submission.

Can anyone suggest any ideas? Thanks


Solution

  • This would very simple to achieve, say you have a tab with 3 fields (field1, field2 and field3) you would writhe something like this:

     <div id="tabs">
      <ul>
        ...
        <li <?=form_error(field_1) || form_error(field_2) || form_error(field_3) ? 'class="error"' : ''?>><a href="#tab-n">Tab with errors</a></li>
        ...
      </ul>
      ...
      <div id="tab-n">
        <?=form_input('field_1')?><?=form_error(field_1)?>
        <?=form_input('field_2')?><?=form_error(field_2)?>
        <?=form_input('field_3')?><?=form_error(field_3)?>
      </div>
      ...
    </div>
    

    And then style the tab(s) with the .error to give a visual clue that it contains errors.