Welcome Guest, Not a member yet? Register   Sign In
Using jquery for form validation in codeigniter
#1

[eluser]esenes[/eluser]
Hi friends,i spend lot of time in this topic,but still cant able to make jquery to work in codeigniter to validate the form...help me in this...
#2

[eluser]LuckyFella73[/eluser]
Hi Esenes,

validating a form has nothing to do with CI directly. If your validation
routine works in a plain HTML document it should run as well when using
Codeigniter.
Please post more information about your problem. Maybe your jquery lib
doesn't load correctly? And please post the code you allready have so we
can have a look at it. With the given information it's impossible to
help you further.
#3

[eluser]esenes[/eluser]
ya i explain my problem

My directory structure as follows

---CI2
------application
------system
------userguide
------js //here jquery files stored
---------jquery-latest.js
---------jquery.validate.js

My View Code

display.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html &gt;

&lt;head&gt;
&lt;title&gt;CodeIgniter Test&lt;/title&gt;


[removed][removed]
[removed][removed]


&lt;style type="text/css"&gt;
* { font-family: Verdana; font-size: 96%; }
label { width: 10em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
p { clear: both; }
.submit { margin-left: 12em; }
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
&lt;/style&gt;

[removed]
$(document).ready(function(){
$("#commentForm").validate();
});
[removed]

&lt;/head&gt;
&lt;body &gt;

&lt;form class="cmxform" id="commentForm" method="post" action="#"&gt;
<label>name
&lt;input type="text" name="name" id="name" class="required" /&gt;
</label>
<p>
<label>age
&lt;input type="text" name="age" id="age" class="required" /&gt;
</label>
</p>
<p>
<label>
&lt;input type="submit" name="button" id="button" value="Submit" /&gt;
</label>
</p>
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;

My Controller

message.php

&lt;?php
// message.php

class message extends CI_Controller
{
function __construct()
{
parent::__construct();
}

function index() {


$this->load->view('display');
}


}
?&gt;


i imported two file in head section jquery-latest.js and jquer,validate.js
#4

[eluser]LuckyFella73[/eluser]
Do you get an error message when submitting the form or
is it just that nothing happens?

Looking at an jquery validate example here (sourcecode browser):
http://jquery.bassistance.de/validate/demo/

Your label tags are not set up right.

Should more look like this:
Code:
<p>
            <label for="age">Age(required, at least 1 character)</label>
            &lt;input id="age" name="age" class="required" minlength="1" /&gt;
        <p>
#5

[eluser]esenes[/eluser]
It doesnt shows anything like error,simple white screen...
#6

[eluser]LuckyFella73[/eluser]
You mean you get a white screen after submitting the form?
In that case your js files seem not to be loaded correctly.
Did you check your sourcecode in your browser (path to
jquery-latest.js and jquery.validate.js) ?
#7

[eluser]esenes[/eluser]
no the code for both jquery-latest and validate are correct..if i worked it away from CI Means its working..but during integration of it with the CI only not working...
#8

[eluser]LuckyFella73[/eluser]
Then I would compare the sourcecode (browser) of your different versions
(CI implemented and pure HTML version). If it's the same the error should
be related to your .htaccess setup.




Theme © iAndrew 2016 - Forum software by © MyBB