Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6589677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:12:18+00:00 2026-05-25T17:12:18+00:00

hi im using codeigniter to generate a form the form error only shows if

  • 0

hi im using codeigniter to generate a form the form error only shows if there is an error for that field i to use twitter-bootstrap for styling so i need a way to add a class of error to both the div (with class=”clear fix”) and the input if (span class=”help-inline”) exists as child.

would prefer not to use query so it will degrade properly but any option would be good

any help would be great. hope that makes sense. code is below thanks

    <?php echo form_open('login'); ?>
    <fieldset>
    <div class="clearfix">
         <?php echo form_label('Email Address: ', 'email_address');?>
         <div class="input"><?php echo form_input('email_address', set_value('email_address'), 'id="email_address" class="xlarge" autofocus ');?>
         <?php echo form_error('email_address', '<span class="help-inline">', '</span>'); ?>
         </div>
    </div><!-- /clearfix -->
    <div class="clearfix">
         <?php echo form_label('Password: ', 'password');?>
         <div class="input"><?php echo form_input('password', '', 'id="password" class="xlarge"');?>
         <?php echo form_error('password', '<span class="help-inline">', '</span>'); ?>
         </div>
    </div><!-- /clearfix -->
    <div class="actions">
       <?php echo form_submit('submit', 'Login', 'class="btn primary"'); ?>
    </div>
    </fieldset>
    <?php echo form_close(); ?>

rendered html(if error is triggered)

<form action="http://unetics.site/index.php/login" method="post" accept-charset="utf-8">
    <div style="display:none">
        <input type="hidden" name="csrf_test_name" value="c0856f469b1f498480881a8512042ccf" />
    </div>
    <fieldset>
        <div class="clearfix">
            <label for="email_address">Email Address: </label>
            <div class="input">
                <input type="text" name="email_address" value="" id="email_address" class="xlarge" autofocus  />             
                <span class="help-inline">The Email Address field is required.</span>                   </div>
        </div><!-- /clearfix -->
        <div class="clearfix">
            <label for="password">Password: </label>
            <div class="input"><input type="text" name="password" value="" id="password" class="xlarge" />
                <span class="help-inline">The Password field is required.</span>
            </div>
        </div><!-- /clearfix -->
        <div class="actions">
            <input type="submit" name="submit" value="Login" class="btn primary" />
        </div>
    </fieldset>
</form> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:12:20+00:00Added an answer on May 25, 2026 at 5:12 pm

    I’d suggest using:

    $('.help-inline').closest('.clear-fix').addClass('error').end().prev('input').addClass('error');
    

    JS Fiddle demo.

    JS Fiddle demo, with your rendered html (note that I’ve changed the jQuery closest() to: closest('.clearfix')).

    Or:

    $('.clear-fix').each(
        function(){
            if ($(this).has('.help-inline')){
                $(this).addClass('error');
                $(this).find('input').addClass('error');
            }
         });
    

    JS Fiddle demo.

    JS Fiddle demo, with your rendered html (note that I’ve changed the jQuery selector to: $('.clearfix')).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using codeigniter. I generate a custom error message from the errors which
I'm using the CodeIgniter calendar class to generate an availability calendar. I use a
I'm using CodeIgniter and I came across an interesting problem. I need to use
I'm using the dompdf plugin for codeigniter: http://codeigniter.com/wiki/PDF_generation_using_dompdf/ to generate pdfs from a form.
I'm using the CodeIgniter PHP framework. I have a simple form that has an
I am using Codeigniter framework and I have a form with input fields. When
I'm using CodeIgniter and I got a model that fetches let's say all recipes
I'm using CodeIgniter with CodeIgniter sessions that are stored in a MySQL database. I
I am using codeigniter. My products page shows all the products we have and
I am using the default Codeigniter page cache e.g.: $this->output->cache(n); My problem is that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.