• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form Validation

#1
[eluser]bigdaddysheikh[/eluser]
Hey Guys,

I am using JS form Validation and a funny thing happens.

When I use CI's tools to create form such as form open/close/textarea/input etc... the form validation does not work. But when I take the output of CI's form creator and paste the hard code into my file the JS validation works.

This is mind boggling. I do not understand what could be causing this discrepency.

CI code:
Code:
<form action="http://localhost:8888/index.php/contact/mail" method="post" class="listForm">    
            <fieldset>
            <legend>Contact</legend>
            <ul>
                <li><label for="Name">Name:</label> &lt;?=form_input('name');?&gt;</li>
                <li><label for="E-mail">E-mail:</label> &lt;?=form_input('email');?&gt;</li>                
                <li><label for="Number">Number:</label> &lt;?=form_input('number');?&gt;</li>
                <li><label for="message">Message:</label> &lt;?=form_textarea('message');?&gt;</li>
            </ul>
        &lt;input type="submit" name="submitbutton" id="submitbutton" value="Submit" /&gt;            </fieldset>
            &lt;?=form_hidden('refer', $_SERVER['PATH_INFO'])?&gt;            
            &lt;?=form_close();?&gt;

Hard Form Code

Code:
&lt;form action="http://localhost:8888/index.php/contact/mail" method="post" class="listForm"&gt;            
  <fieldset>
            <legend>Contact</legend>
            <ul>
                <li><label for="Name">Name:</label> &lt;input name="name" type="text" id="name" value="" size="50" maxlength="500"  /&gt;

</li>
                <li><label for="E-mail">E-mail:</label> &lt;input name="email" type="text" id="email" value="" size="50" maxlength="500"  /&gt;
</li>                
                <li><label for="Number">Number:</label> &lt;input name="number" type="text" id="number" value="" size="50" maxlength="500"  /&gt;
</li>
                <li><label for="message">Message:</label> &lt;textarea name="message" cols="90" rows="12" id="message" &gt;&lt;/textarea>
</li>
            </ul>
        
        &lt;input type="submit" name="submitbutton" id="submitbutton" value="Submit" /&gt;            </fieldset>
                
&lt;/form&gt;

#2
[eluser]Seppo[/eluser]
I believe CI helper functions does not append the id if you don't specify, and that's why your validation is failing... Try something like
Code:
&lt;?=form_input('name', '', 'id="name"');?&gt;

#3
[eluser]bigdaddysheikh[/eluser]
Hey,

I the hard code that I have posted is the CI code that is generated in the html. By default it places those id fields. I will try your method when I get back home tonight.

Thanks for the help.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.