简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM