Welcome Guest, Not a member yet? Register   Sign In
Form Validation
#1

[eluser]Thiago Leao[/eluser]
Hi friends,

What is happening, I'm validating a form.
But the error messages are reaching another form on the same page.

Anyone know please tell me, how do I restrict the error messages to only one form?

thanks!
#2

[eluser]Deveron[/eluser]
Hi Thiago,
do you use unique input names?
Every form should have his own unique name as well.
#3

[eluser]Thiago Leao[/eluser]
Are with different names!

1º form

Code:
<?php
echo validation_errors();
$attribut = array('name' => 'form', 'id' => 'form');
echo form_open(base_url().'administracao/home/login', $attribut);
?>
                <li>&lt;?php echo img(array('src' => 'assets/images/title_login.jpg', 'alt' => "Login", 'title' => "Faça o Login!"));?&gt;</li>
                <li>&lt;input type="text" name="login" /&gt;&lt;/li>
                <li>&lt;?php echo img('assets/images/title_senha.jpg');?&gt;</li>
                <li>&lt;input type="text" name="senha" /&gt; <a href="#">&lt;?php echo img('assets/images/bt_ok.jpg');?&gt;</a></li>
                <li><a href="#">&lt;?php echo img('assets/images/title_esqueceu.jpg');?&gt;</a></li>
                &lt;? echo form_close(); ?&gt;


2º Form

Code:
&lt;?
        //echo validation_errors();        
        $attributes = array('name' => 'myform', 'id' => 'myform');
        echo form_open(base_url().'registrar/insert', $attributes);
        
        ?&gt;
        
        <div id="registro">
            <ul>
                <li>
                    <label for="nome">&lt;?php echo img('assets/images/form_nome.jpg');?&gt;</label>
                    &lt;?php echo form_error('nome'); ?&gt;
                    &lt;input name="nome" type="text" class="input_registro" id="nome" /&gt;
                </li>

                <li>
                    <label for="login">&lt;?php echo img('assets/images/form_apelido.jpg');?&gt;</label>
                    &lt;?php echo form_error('login'); ?&gt;
                    &lt;input name="login" type="text" class="input_registro" id="login" /&gt;
                </li>
                <li>
                    <label for="senha">&lt;?php echo img('assets/images/form_senha.jpg');?&gt;</label>
                    &lt;?php echo form_error('senha'); ?&gt;
                    &lt;input name="senha" type="password" class="input_registro" id="senha" /&gt;
                </li>
                <li>
                     &lt;input name="termo" type="checkbox" class="check_registro" id="termo" /&gt;
                  &lt;?php echo img('assets/images/form_termos.jpg');?&gt;
                </li>
                <li>&lt;?php echo form_submit('mysubmit', 'ok') . "\n"; ?&gt;</li>
            </ul>
        </div>
        
        &lt;? echo form_close(); ?&gt;
#4

[eluser]Deveron[/eluser]
In your login and register form you are using input fields with the same name. 1: login 2: senha.
I think you have to change the names in one of your forms.
#5

[eluser]InsiteFX[/eluser]
Because you are using echo validation_errors();
in your first form which echo's all form errors!

InsiteFX
#6

[eluser]Thiago Leao[/eluser]
was the echo!
I took and it worked!!
thanks




Theme © iAndrew 2016 - Forum software by © MyBB