Using jquery for form validation in codeigniter |
[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...
[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.
[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"> <html > <head> <title>CodeIgniter Test</title> [removed][removed] [removed][removed] <style type="text/css"> * { 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; } </style> [removed] $(document).ready(function(){ $("#commentForm").validate(); }); [removed] </head> <body > <form class="cmxform" id="commentForm" method="post" action="#"> <label>name <input type="text" name="name" id="name" class="required" /> </label> <p> <label>age <input type="text" name="age" id="age" class="required" /> </label> </p> <p> <label> <input type="submit" name="button" id="button" value="Submit" /> </label> </p> </form> </body> </html> My Controller message.php <?php // message.php class message extends CI_Controller { function __construct() { parent::__construct(); } function index() { $this->load->view('display'); } } ?> i imported two file in head section jquery-latest.js and jquer,validate.js
[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>
[eluser]esenes[/eluser]
It doesnt shows anything like error,simple white screen...
[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) ?
[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...
[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. |
Welcome Guest, Not a member yet? Register Sign In |