Welcome Guest, Not a member yet? Register   Sign In
validation and css
#1

[eluser]tirso[/eluser]
hi to all

What's wrong for my code, I want to change the background of field if error. Display message is work's fine only applying css.

any suggestion would greatly appreciated

thanks in advance

Tirso

here is my controller

Code:
function signup(){
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
            
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
        $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
        $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
                    
        if ($this->form_validation->run() == FALSE){
            $html['page'] = 'wishlist/signup';                
            $this->load->view('template_wishlist',$html);
        }
        else{
            $html['page'] = 'wishlist/signup';                
            $this->load->view('template_wishlist',$html);        
        }    

    }

this will display message which is no problem

Code:
<div style="width: 340px" align="center">
    &lt;?php
       echo validation_errors('<div class="error">', '</div>');
    ?&gt;
</div>

in my view to apply my css
Code:
&lt;input name="username" type="text" class="highlight5" id="username" size="30" class="&lt;?php echo (form_error('username') == '') ? '': 'highlight-field';?&gt;"/&gt;
#2

[eluser]slowgary[/eluser]
What you're doing should work, except you already have a class attribute in your input tag. Try this instead:
Code:
&lt;input name="username" type="text" id="username" size="30" class="highlight5&lt;?php echo (form_error('username') == '') ? '': ' highlight-field';?&gt;"/&gt;
#3

[eluser]tirso[/eluser]
hi slowgary,

I didn't notice that I have already declared a class.

Thank you so much

Tirso




Theme © iAndrew 2016 - Forum software by © MyBB